Jump to content

pollitoyeye

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by pollitoyeye

  1. Using this

        public boolean onBlockActivated(World world, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
                if(!world.isRemote)
                {
                	TileEntityPc t = (TileEntityPc) world.getBlockTileEntity(par2 +1, par3, par4);
                           	par5EntityPlayer.addChatMessage(TileEntityPc.visitor1);
                }
                return true;  
                
    }

     

    But it says me that i have to change visitor to static.

    Where is the problem in this code?

  2. Hi, i made a block that stores variables in a tileentity so if i have another block how can i make it check the other block variable if is in x-1. For expample if i place the first block in x:0 y:10 z:0 thath has a variable j with the valor 4 and i place the second in x:-1 y:10 z:0

    how can i make the second acces j valor?

  3. Tried this

    public void sendChangeToServer(){
        ByteArrayOutputStream bos = new ByteArrayOutputStream(;
        DataOutputStream outputStream = new DataOutputStream(bos);
        try {
            outputStream.writeInt(flag);
            outputStream.writeChars(visitor1);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
                   
        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.channel = "GenericRandom";
        packet.data = bos.toByteArray();
        packet.length = bos.size();
    
        PacketDispatcher.sendPacketToServer(packet);
    }

    but also not working ;(

  4. I have the following code, and its supposed that once a person interacts with the blocks nobody more can, all works great but when i close the world and open it again, the person with the same name of the variable cant open it.

    package Yourmod;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.Minecraft;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    
    public class TileEntityPc extends TileEntity {
    
        String visitor1="none";
        int flag = 0;
        public void processActivate(EntityPlayer par5EntityPlayer, World world, int par2, int par3, int par4) {
    [color=red]        if (this.visitor1 == "none")    {
        	this.visitor1=par5EntityPlayer.getEntityName();
        }[/color]
        	//comprueba si el bloque contiguo es la bandera encendida. Ejemplo con dirt
        	if (world.getBlockId(par2 -1, par3, par4) == Block.glowStone.blockID)
            { 
       [color=red]     if (this.visitor1 == par5EntityPlayer.getEntityName()){[/color]
            	//aqui comprobamos si el jugador tiene la bandera, en este caso lo hago con un diamante.
            	if( par5EntityPlayer.inventory.getStackInSlot(par5EntityPlayer.inventory.currentItem) != null)
            	{
            	        String item = par5EntityPlayer.inventory.getStackInSlot(par5EntityPlayer.inventory.currentItem).toString();
            	        String check = new ItemStack(Item.diamond).toString();
            	        if( item.equals(check) )
            	        {
            	        // si tiene el diamante
            	        	flag = flag + 1;
                           	par5EntityPlayer.addChatMessage("You stored the flag.");
                           	par5EntityPlayer.addChatMessage("Captured flags: " + flag);
                           	par5EntityPlayer.inventory.consumeInventoryItem(Item.diamond.itemID);
         	               world.notifyBlockChange(xCoord, yCoord, zCoord, 2);
         	               if (flag == 10) {
         	            	   //Aqui te daria l0 pokeballs
         	            	  par5EntityPlayer.addChatMessage("You have obtained 10 Pokeballs");
         	               }
         	               if (flag == 50) {
         	            	   //Aqui te daria el pal pad
         	            	  par5EntityPlayer.addChatMessage("You have obtained a Pal Pad");
         	               }
         	               if (flag == 100) {
         	            	   //Aqui te daria 5 caramelos raros
         	            	  par5EntityPlayer.addChatMessage("You have obtained 5 Rare Candy");
         	               }
         	               if (flag == 200) {
         	            	   //Aqui te daria el mapa del subsuelo
         	            	  par5EntityPlayer.addChatMessage("You have obtained The Underground Map");
         	               }
         	               if (flag == 500) {
         	            	   //Aqui te daria unna masterball
         	            	  par5EntityPlayer.addChatMessage("You have obtained a Masterball");
         	               }
         	              if (flag == 1000) {
        	            	   //Aqui te daria el rango platino
        	            	  par5EntityPlayer.addChatMessage("Congratulations, you have reached the Platinum Flag");
        	               }
            	        }
            	}
            else
            {
                    // si no lo tiene
             	   par5EntityPlayer.addChatMessage("Welcome back " + this.visitor1);
                   par5EntityPlayer.addChatMessage("Captured flags: " + flag);
                   world.notifyBlockChange(xCoord, yCoord, zCoord, 2);
                   if (flag < 10){
                	   par5EntityPlayer.addChatMessage("Next reward: 10 Pokeballs (10 flags)");
                   } else {
                	   if (flag < 50){
                		   par5EntityPlayer.addChatMessage("Next reward: Pal Pad (50 flags)"); 
                	   } else {
                		   if (flag < 100){
    	            		   par5EntityPlayer.addChatMessage("Next reward: 5 Rare Candy (100 flags)"); 
    	            	   } else{
    	            		   if (flag < 200){
    		            		   par5EntityPlayer.addChatMessage("Next reward: Underground Map (200 flags)"); 
    		            	   } else {
    		            		   if (flag < 500){
    			            		   par5EntityPlayer.addChatMessage("Next reward: Masterball (500 flags)"); 
    			            	   } else{
    			            		   if (flag < 1000){
    				            		   par5EntityPlayer.addChatMessage("Next reward: Plantinum Flag (1000 flags)"); 
    				            	   } else {
    				            		   par5EntityPlayer.addChatMessage("Next reward: None"); 
    				            	   }
    			            	   }
    		            	   }
    	            	   }
    	            		  
                	   }
                		   
                   }
            }
            } else{
                par5EntityPlayer.addChatMessage("Welcome to the " + this.visitor1 + " PC´s");
                par5EntityPlayer.addChatMessage("Captured flags: " + flag);
                world.notifyBlockChange(xCoord, yCoord, zCoord, 2);
            } 
            }
       else {
       par5EntityPlayer.addChatMessage("Systems are disabled");
        }
        }
        @Override
        public void readFromNBT(NBTTagCompound nbt)
    {
        super.readFromNBT(nbt);
        this.visitor1 = nbt.getString("visitor1");
        this.flag = nbt.getInteger("flag");
    }
    
    @Override
    public void writeToNBT(NBTTagCompound nbt)
    {
        super.writeToNBT(nbt);
        nbt.setString("visitor1", visitor1);
        nbt.setInteger("flag", flag);
    }
    }

    Thx for your help

  5. I´ve created a block and I dont know how to make thath if I put two blocks of this type both have independent variables and when clossing the game, both variables get saved to load them again when loading the world.

    At the moment I have this code:

    public class block2 extends Block {
    private int i = 0;
    public block2(int id, Material Material) {
    	super(id, Material);
    }
    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
    if (!par1World.isRemote)
    {
        this.i = (this.i) + 1;
    	par5EntityPlayer.addChatMessage("Numero de banderas obtenidas hasta el momento: " + i);
    return true;
    }
    return false;
    }
    }
    

    The variable I want to do is i

  6. Hi, i made the following code, how can i make thath once is activated controlls get inverted for 50 seconds. So pressing w you will go downwards and with the d you will go to the left.

    public class trampa extends Block {
    
    public trampa(int id, Material Material) {
    	super(id, Material);
    }
        /**
         * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
         * cleared to be reused)
         */
        public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            float f = 0.125F;
            return AxisAlignedBB.getAABBPool().getAABB((double)par2, (double)par3, (double)par4, (double)(par2 + 1), (double)((float)(par3 + 1) - f), (double)(par4 + 1));
        }
    
        /**
         * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
         */
        public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
        {
        	if (par5Entity instanceof EntityPlayer) {
        		//here goes the acction
        }
        }
    }

    Thx very much, and sorry for my bad english.

  7. I´ve tried the following code for making a block pull away the players, but it also works with the other entitys.

    How can i make it work only in players?.

    Thx

    public class trampa extends Block {
    
    public trampa(int id, Material Material) {
    	super(id, Material);
    }
        /**
         * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
         * cleared to be reused)
         */
        public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            float f = 0.125F;
            return AxisAlignedBB.getAABBPool().getAABB((double)par2, (double)par3, (double)par4, (double)(par2 + 1), (double)((float)(par3 + 1) - f), (double)(par4 + 1));
        }
    
        /**
         * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
         */
        public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5EntityPlayer)
        {
            par5EntityPlayer.motionX *= -10D;
            par5EntityPlayer.motionZ *= -10D;
        }
    }
    
    

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.