Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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");
    }
}

 

  • 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?

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.

  • 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 by Tikaji

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.