Posted July 19, 201510 yr I need help with placing a custom lily pad on top of water. Ive looked in the original lilypad classes: BlockLilyPad/ItemLilyPad, but i cant seen to make it work. This code seems interesting: public class ItemLilyPad extends ItemColored { private static final String __OBFID = "CL_00000074"; public ItemLilyPad(Block block) { super(block, false); } public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true); if (movingobjectposition == null) { return itemStackIn; } else { if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { BlockPos blockpos = movingobjectposition.getBlockPos(); if (!worldIn.isBlockModifiable(playerIn, blockpos)) { return itemStackIn; } if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn)) { return itemStackIn; } BlockPos blockpos1 = blockpos.up(); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1)) { // special case for handling block placement with water lilies net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1); worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState()); if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled()) { blocksnapshot.restore(true, false); return itemStackIn; } if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } playerIn.triggerAchievement(StatList.objectUseStats[item.getIdFromItem(this)]); } } return itemStackIn; } } Copied the code and made a ItemBlock but still can't make it work
July 19, 201510 yr Author I found out I had to add something from the BlockBush.class BlockBush.class @Override public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) { if (this == Blocks.wheat) return net.minecraftforge.common.EnumPlantType.Crop; if (this == Blocks.carrots) return net.minecraftforge.common.EnumPlantType.Crop; if (this == Blocks.potatoes) return net.minecraftforge.common.EnumPlantType.Crop; if (this == Blocks.melon_stem) return net.minecraftforge.common.EnumPlantType.Crop; if (this == Blocks.pumpkin_stem) return net.minecraftforge.common.EnumPlantType.Crop; if (this == Blocks.deadbush) return net.minecraftforge.common.EnumPlantType.Desert; if (this == Blocks.waterlily) return net.minecraftforge.common.EnumPlantType.Water; if (this == Blocks.red_mushroom) return net.minecraftforge.common.EnumPlantType.Cave; if (this == Blocks.brown_mushroom) return net.minecraftforge.common.EnumPlantType.Cave; if (this == Blocks.nether_wart) return net.minecraftforge.common.EnumPlantType.Nether; if (this == Blocks.sapling) return net.minecraftforge.common.EnumPlantType.Plains; if (this == Blocks.tallgrass) return net.minecraftforge.common.EnumPlantType.Plains; if (this == Blocks.double_plant) return net.minecraftforge.common.EnumPlantType.Plains; if (this == Blocks.red_flower) return net.minecraftforge.common.EnumPlantType.Plains; if (this == Blocks.yellow_flower) return net.minecraftforge.common.EnumPlantType.Plains; return net.minecraftforge.common.EnumPlantType.Plains; } MyBlock.class @Override public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) { if (this == BlockManager.BushLotus) return net.minecraftforge.common.EnumPlantType.Water; return net.minecraftforge.common.EnumPlantType.Plains; }
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.