Posted April 6, 20169 yr I have made an OnBlockActivated method in my custom crop which causes the crop to drop 1-3 apples when right clicked. However, how would I make it so it also goes back a stage? Help much appreciated thank you. Crop class: public class IYPLettuceCrop extends BlockCrops{ public IYPLettuceCrop(String name){ this.setUnlocalizedName(name); } public Item getSeed(){ return IYPItems.LettuceSlice; } public Item getCrop(){ return IYPItems.Lettuce; } public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { int i = (((Integer) state.getValue(AGE)).intValue()); if (i > 6) Block.spawnAsEntity(worldIn, pos, new ItemStack(Items.apple, new Random().nextInt(3) + 1)); return false; } @Override public java.util.List<ItemStack> getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { List<ItemStack> ret = new ArrayList<ItemStack>(); int i = (((Integer) state.getValue(AGE)).intValue()); if (i < 7) ret.add(new ItemStack ( this.getSeed(), 1, 0)); else if (i > 6) { ret.add(new ItemStack ( this.getCrop(), 1, 0)); } return ret; } } This is my first thread thus I'm not sure how to create text boxes to place your code, sorry about that!
April 6, 20169 yr You either click the '#' symbol in the toolbar or manually type [ code ] your code here [ /code ] without the spaces. As for your issue, you need to set the block state with the appropriate AGE property, e.g. world.setBlockState(pos, state.withProperty(AGE, 1)); Note that the actual code may be slightly different - I don't have an IDE in front of me. http://i.imgur.com/NdrFdld.png[/img]
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.