Posted April 11, 20205 yr From what I understand, I should be able to subscribe to the BlockEvent.HarvestDropsEvent. However, I've found that it doesn't seem to work. When I subscribe to BlockEvent, it works just fine. Am I doing something wrong? Here is my event handler class. @Mod.EventBusSubscriber(modid = ModInfo.MOD_ID, bus = Bus.FORGE) public class CrookHandler { @SubscribeEvent public static void handleEvent(BlockEvent event) { LogUtil.info("Received Block Event"); } @SubscribeEvent public static void handleCrookEvent(BlockEvent.HarvestDropsEvent event) { LogUtil.info("Fired handleCrookEvent"); if (event.getWorld().isRemote()) return; if (event.getHarvester() == null) return; if (event.isSilkTouching()) return; ItemStack held = event.getHarvester().getHeldItemMainhand(); if ((held.getItem() instanceof CrookBaseItem)) { return; } LogUtil.info("Recognized crook"); } }
April 11, 20205 yr I believe you should be using loot tables. Here's a thread I remembered that's related: https://www.minecraftforge.net/forum/topic/74752-harvestdropsevent-not-working-as-expected/
April 11, 20205 yr Author Is this the only way to handle block drops? I want to be able to check a specific set of conditions (ie the block broken and the tool used) and also support adding block drops for the tool from other mods (Hopefully that was clear). Is there no way to handle block drops programmatically, or must I use loot tables?
April 11, 20205 yr 33 minutes ago, diesieben07 said: Correct, loot tables are the only way to specify block drops. Loot tables support conditions (you can even add your own, custom coded conditions). And functions as well. For example I have a block that uses a blockstate to store variants (its easier to deal with changing an integer value than change to a new block for the majority of harvesting cases), but needs to drop different items (due to item variants not really being a thing any more) when silk-touched (a less common harvesting situation), so I created a function that generates the correct item. Additionally, should you have an effect that would require the HarvestDropsEvent to modify loot in some way (e.g. an enchantment that causes skeletons to drop bonemeal instead of bones), check out the Global Loot Modifiers. 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.
April 11, 20205 yr Author Would you happen to have/point me to an example of using a function for your loot table? It sounds a lot like what I would like to do. Edited April 11, 20205 yr by Tikaji
April 11, 20205 yr The code: https://github.com/Draco18s/ReasonableRealism/tree/1.14.4/src/main/java/com/draco18s/harderores/loot/function The loot table: https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/harderores/loot_tables/blocks/ore_hardiron.json#L27 Registering things: https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/HarderOres.java#L97-L99 (Note: I haven't worked on the code in some time and registration may have changed to be done as a registry object like blocks and items) 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.