Jump to content

TheGlobefish

Members
  • Posts

    1
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

TheGlobefish's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, I'm new to modding, and I am trying to get an item (baked potato) to drop from leaves occasionally. I registered the eventbus: MinecraftForge.EVENT_BUS.register(new YeastEventHandler()); in my init method, and have this code in my YeastEventHandler: package com.yeast.yeastmod; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class YeastEventHandler { @SubscribeEvent public void checkLeave(BlockEvent.HarvestDropsEvent event) { System.out.println("Some event called"); //Check the block state to find out if the Block is Leaves if(event.state == Blocks.leaves) { //Add the new drop, we can't set event.drops because it is final. This will add it to the list of possible drops for leaves System.out.println("This is a leaf."); event.drops.add(new ItemStack(Items.baked_potato)); } } } When I break any block, my console says "Some event called", confirming that it knows I broke the block. However, when I break a leaf block, I do not get the output "This is a leaf." I have tried using "Blocks.leaves" and "Blocks.leaves2", and both ways my code cannot detect if the block I broke is a leaf. What am I doing wrong? Any help is appreciated, -TheGlobefish
×
×
  • Create New...

Important Information

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