Trying to use a HarvestDropsEvent to change the drops of logs. Was just trying to change the block drop dirt instead of logs. My event is registered. I registered the entire class where a few other events I was testing were placed. I used a similar method to make leaves drop cobblestone in the same class and that works fine. The problem I'm running into with logs is that the log block is still dropped and no dirt block is dropped.
@SubscribeEvent
public void LogsDropDirt(HarvestDropsEvent event)
{
if(event.getHarvester() == null)
{
if(event.getState().getBlock() instanceof BlockLog)
{
event.getDrops().clear();
event.getDrops().add(new ItemStack(Blocks.DIRT));
}
}
}
https://pastebin.com/igx5fy17
I've also tried it without the first if statement. That does not work either. Is there a better method to change block drops or is there something missing?
@SubscribeEvent
public void LogsDropDirt(HarvestDropsEvent event)
{
if(event.getState().getBlock() instanceof BlockLog)
{
event.getDrops().clear();
event.getDrops().add(new ItemStack(Blocks.DIRT, 1));
}
}
https://pastebin.com/rRUngcjL
Here is the leaves dropping cobblestone I used, that worked just fine, for reference.
@SubscribeEvent
public static void DropLeaf(HarvestDropsEvent event)
{
if(event.getState().getBlock() instanceof BlockLeaves)
{
event.getDrops().add(new ItemStack(Blocks.COBBLESTONE));
}
}
https://pastebin.com/DLLGbEa5