How do I make an item with the property of bone meal?

Started by MrFrozen on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make an item with the property of bone meal?

How do I make an item with the property of bone meal?

Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you want this item to…
Tue, 06/09/2020 - 18:32

If you want this item to affect vanilla minecraft trees or seeds I think you will need to code that, if you want this item to affect your custom mod elements you just need to create a procedure inside each element(custom seed or sappling) for right clicking if player has this item in main hand do random chance to destroy the block and set the next stage of this block on the same x y z, do this procedure again for the next stage element and so on until the seed or tree is full grown 

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you want this item to…
Tue, 06/09/2020 - 23:24

If you want this item to affect vanilla minecraft trees or seeds I think you will need to code that

To extend, if you know how to code this will prove helpful;

   public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos pos, net.minecraft.entity.player.PlayerEntity player) {
      BlockState blockstate = worldIn.getBlockState(pos);
      int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, blockstate, stack);
      if (hook != 0) return hook > 0;
      if (blockstate.getBlock() instanceof IGrowable) {
         IGrowable igrowable = (IGrowable)blockstate.getBlock();
         if (igrowable.canGrow(worldIn, pos, blockstate, worldIn.isRemote)) {
            if (worldIn instanceof ServerWorld) {
               if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, blockstate)) {
                  igrowable.grow((ServerWorld)worldIn, worldIn.rand, pos, blockstate);
               }

               stack.shrink(1);
            }

            return true;
         }
      }

      return false;
   }

(taken from BoneMealItem)