Jump to content

Recommended Posts

Posted

I've been looking around to try and figure some of this out, and I haven't been able to come up with a functional implementation.

 

I understand the structure of the loot table JSON files: https://pastebin.com/szW00wy2

 

I have Providers registered with a custom DataGenerator class for ItemModels and Recipes, both of which work, but looking in the

net.minecraftforge.client.model.generators

package, there doesn't seem to be an equivalent superclass for generating loot tables.

 

My end goal is to replace the Porkchop drops of Hoglins with my new custom food item.

Posted
16 minutes ago, DemonicElectronic said:

net.minecraftforge.client.model.generators

That's for client providers for reference. Forge only creates providers whenever something needs to be expanded or created. In the case of loot tables, the data providers are a vanilla system and would be located under 'net.minecraft.data'. You can use those references and refer to mcjty's explanation on it.

19 minutes ago, DemonicElectronic said:

My end goal is to replace the Porkchop drops of Hoglins with my new custom food item.

Well, I wouldn't suggest replacing the drops but use a global loot modifier, but that's just an opinion.

Posted (edited)
20 hours ago, ChampionAsh5357 said:

That's for client providers for reference. Forge only creates providers whenever something needs to be expanded or created. In the case of loot tables, the data providers are a vanilla system and would be located under 'net.minecraft.data'. You can use those references and refer to mcjty's explanation on it.

Well, I wouldn't suggest replacing the drops but use a global loot modifier, but that's just an opinion.

I've just managed to get the example global loot modifier from the Forge test mods working, and it's exactly what I'm looking for, thanks.

 

A note for anyone who comes across this thread in the future: there's a slight bug in the documentation linked above, where, even though it's the 1.16.x Forge docs, the link at the bottom of the page leads to the 1.15.x reference implementation on Github. Here's the code for 1.16: https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java

 

The 1.16 version uses DeferredRegisters to register the enchantment and global loot modifiers, as well as data generators to produce the files, whereas the 1.15 version does everything in an older way.

Edited by DemonicElectronic
Paragraph formatting
Posted

Feel free to submit a pull request to update the docs

https://github.com/MinecraftForge/Documentation

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
On 12/18/2020 at 3:03 AM, ChampionAsh5357 said:

That's for client providers for reference. Forge only creates providers whenever something needs to be expanded or created. In the case of loot tables, the data providers are a vanilla system and would be located under 'net.minecraft.data'. You can use those references and refer to mcjty's explanation on it.

Well, I wouldn't suggest replacing the drops but use a global loot modifier, but that's just an opinion.

I've managed to get this working with blocks, but not with entities. The best I've managed to do is to get EntityHasProperty.test() to fire when I kill any mob, but the `target` property is null, which casues a `NullPointerException`.

 

Here's the data generation code:
 

public class ModGlobalLootModifierProvider extends GlobalLootModifierProvider {
    public ModGlobalLootModifierProvider(DataGenerator gen) {
        super(gen, Mod.MOD_ID);
    }

    @Override
    protected void start() {
        add("hoglin_meat_modifier", RegistryHandler.HOGLIN_MEAT_MODIFIER.get(), new HoglinMeatModifier(
            new ILootCondition[] {
                    EntityHasProperty.builder(LootContext.EntityTarget.THIS, EntityPredicate.Builder.create().type(EntityType.HOGLIN)).build(),
            }
        ));
    }
}

 

which generates the following file:

{
  "conditions": [
    {
      "condition": "minecraft:entity_properties",
      "predicate": {
        "type": "minecraft:hoglin"
      },
      "entity": "this"
    }
  ],
  "type": "modid:hoglin_meat_modifier"
}

 

As I said before, all this does is cause a NullPointerException when EntityHasProperty.test() is called. I can't figure out why, though, because I pass both parameters into EntityHasProperty.build(). Maybe something is going wrong when the file is deserialized? The EntityPredicate is correct at runtime, anyway.

 

15 hours ago, Draco18s said:

Feel free to submit a pull request to update the docs

https://github.com/MinecraftForge/Documentation

I've forked the repo and have patched the link -- I'll update the rest of the documentation to match the example code it links to, then set up the pull request.

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.