Jump to content

Recommended Posts

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

 

Posted

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?

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

Posted (edited)

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
Posted

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.