Posted April 10, 201510 yr goods i been doing somethings whith blocks but alredy dont get how properties work i make some hot item and want to cool them rigth clickin and filled cauldrun in this case a wanna get if the cauldrun has water but has not realize how to get the value of a properti from a block here im doing // ########################################################################3 @Override public ItemStack onItemUseFinish(ItemStack lingote, World worldIn, EntityPlayer playerIn) { if (!worldIn.isRemote) { MovingObjectPosition mov = Minecraft.getMinecraft().objectMouseOver; BlockPos pos = mov.getBlockPos(); EnumFacing sid= mov.sideHit; IBlockState blkst = worldIn.getBlockState(pos); Block blk = blkst.getBlock(); chat.chatm(playerIn, "Block="+blk.getUnlocalizedName()); chat.chatm(playerIn, "BlockState="+blkst.getPropertyNames() ); //level = blkst.getValue(property); //Block caldero = Blocks.cauldron; //if (blk == caldero) }// is ! remote return lingote; } // ########################################################################3 this return [11:09:58] [Client thread/INFO]: [CHAT] Block=tile.cauldron [11:09:58] [Client thread/INFO]: [CHAT] BlockState=[PropertyInteger{name=level, clazz=class java.lang.Integer, values=[0, 1, 2, 3]}] i need to now the value of "name=level" how i do thath
April 10, 201510 yr Author well how do you instantiate that the get the value as a int thaths the part i dont get int level = blkst.LEVEL.getValue(); //wrong int level = blkst.getValue(blkst.LEVEL); //wrong
April 10, 201510 yr Author this blocks in 1.8 has become a little anfractuous (complicadito) to get it work but its done // ######################################################################################3 @Override public ItemStack onItemRightClick(ItemStack lingote, World worldIn,EntityPlayer playerIn) { if (!worldIn.isRemote) { MovingObjectPosition mov = Minecraft.getMinecraft().objectMouseOver; BlockPos pos = mov.getBlockPos(); EnumFacing sid= mov.sideHit; IBlockState blkst = worldIn.getBlockState(pos); Block blk = blkst.getBlock(); Block caldero = Blocks.cauldron; IBlockState calderost=caldero.getDefaultState(); if (blk == caldero ) { PropertyInteger LEVEL = PropertyInteger.create("level", 0, 3); int levelInt = (Integer) blkst.getValue(BlockCauldron.LEVEL) ; if ( levelInt > 0 ) { worldIn.spawnEntityInWorld(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(MercenaryModItems.aceroMercenario, 1, 0))); worldIn.playSoundAtEntity(playerIn, "modmercenario:extingir", 1.0F, 1.0F ); playerIn.inventory.consumeInventoryItem(MercenaryModItems.hierroAlrojo); } levelInt--; if (levelInt < 0) { levelInt=0; } worldIn.setBlockState(pos, calderost.withProperty(LEVEL, Integer.valueOf(levelInt)) ); } }// is ! remote playerIn.setItemInUse(lingote, this.getMaxItemUseDuration(lingote)); return lingote; } // ####################################################################################3 [/code]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.