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.

DemonicElectronic

Members
  • Joined

  • Last visited

  1. 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. 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.
  2. 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.
  3. 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.
  4. So would I be correct to assume that the 'solution' to this problem is to create a custom machine, with a custom recipe type, which is capable of doing this?
  5. I have a question regarding smelting recipes - is it possible to copy enchantment data from the input item of a smelting recipe to the output? I'm using Data Generators to create my recipe JSON files. Can someone please either tell me how to achieve this, or point me to a reference implementation in an existing mod? Thank you.

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.