So, I created an event handler to check when a leaf is harvested and I want to drop some sticks. I found some help online and it got me to where I am now, but I am having trouble determining if the event.block is equal to Blocks.leaves. The issue is that event.block gives me an error : "block cannot be resolved or is not a field".
I found no help online through searching and I'm not sure why this is happening.
I tried attaching an image of how the error looks, but it wont let me. So here is my Event Handler, and my CommonProxy where I initialize the event bus.
MyEventHandler.java
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 MyEventHandler {
@SubscribeEvent
public static void onDrops(BlockEvent.HarvestDropsEvent event){
if( event.block == Blocks.leaves && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == RealismItems.flintKnife){
event.drops.add(new ItemStack(Items.stick, 2));
}
}
}
CommonProxy.java
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class CommonProxy {
public void preInit(FMLPreInitializationEvent e) {
RealismItems.createItems();
RealismBlocks.createBlocks();
}
public void init(FMLInitializationEvent e) {
RealismCrafting.initCrafting();
MinecraftForge.EVENT_BUS.register(new MyEventHandler());
}
public void postInit(FMLPostInitializationEvent e) {
}
}
Any assistance with this would be greatly appreciated.