Posted September 29, 20187 yr 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 Edited September 29, 20187 yr by McDogerts Solved
September 29, 20187 yr Author 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.
September 29, 20187 yr 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.
September 29, 20187 yr Author 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 September 29, 20187 yr by McDogerts
September 29, 20187 yr 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.