Jump to content

[Solved][1.12.2] HarvestDropsEvent not changing block drop for Logs


Recommended Posts

Posted (edited)

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.
 

  1. @SubscribeEvent
  2. public void LogsDropDirt(HarvestDropsEvent event)
  3. {
  4.        
  5.     if(event.getHarvester() == null)
  6.     {
  7.         if(event.getState().getBlock() instanceof BlockLog)
  8.         {
  9.             event.getDrops().clear();
  10.             event.getDrops().add(new ItemStack(Blocks.DIRT));
  11.         }
  12.     }
  13.        
  14. }

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?

  1. @SubscribeEvent
  2. public void LogsDropDirt(HarvestDropsEvent event)
  3. {
  4.     if(event.getState().getBlock() instanceof BlockLog)
  5.     {
  6.         event.getDrops().clear();
  7.         event.getDrops().add(new ItemStack(Blocks.DIRT, 1));
  8.     }
  9. }

https://pastebin.com/rRUngcjL

 

 

Here is the leaves dropping cobblestone I used, that worked just fine, for reference.

  1. @SubscribeEvent
  2. public static void DropLeaf(HarvestDropsEvent event)
  3. {
  4.    
  5.     if(event.getState().getBlock() instanceof BlockLeaves)
  6.     {
  7.         event.getDrops().add(new ItemStack(Blocks.COBBLESTONE));
  8.     }
  9. }

https://pastebin.com/DLLGbEa5

Edited by McDogerts
Solved
Posted

Comment just to post what I changed. Because I wasted 4 hours on this. The @Subscribe event will only work for me if I make a static method with existing Minecraft Blocks. Custom blocks I've added in do not need to be set as a static method. This was the only difference why the leaves drop worked and the dirt drop did not.

Posted
2 hours ago, McDogerts said:

The @Subscribe event will only work for me if I make a static method with existing Minecraft Blocks. Custom blocks I've added in do not need to be set as a static method. This was the only difference why the leaves drop worked and the dirt drop did not.

 

This is bullshit and makes no sense.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
3 hours ago, Draco18s said:

 

This is bullshit and makes no sense.

I was just posting was I tried and saw that worked. You can see that I posted in the original post literally the only difference between the method that i said was working and the one that wasn't is that the working was set as a static method. When I set the LogsDropDirt method to static it worked. A custom block I have added in was not set as a static method and worked just fine. This is why I said the event will only work for ME in this fashion. Not that this is how it works in all cases.

Edited by McDogerts
Posted

Because you registered your event handler class using an annotation, which requires the methods to be static.

 

The part that makes no sense is that your non-static function was not being called for vanilla blocks but was for modded blocks.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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