Posted March 28, 20223 yr How does one add items to vanilla mob loot tables with global loot modifiers? I already managed to make it work with blocks, but mobs don't seem to work. Here's my code: LootAdditionModifier: public class LootAdditionModifier extends LootModifier { private final Item addition; protected LootAdditionModifier(ILootCondition[] conditionsIn, Item addition) { super(conditionsIn); this.addition = addition; } @Nonnull @Override protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { // generatedLoot is the loot that would be dropped, if we wouldn't add or replace // anything! generatedLoot.add(new ItemStack(addition, 1)); return generatedLoot; } public static class Serializer extends GlobalLootModifierSerializer<LootAdditionModifier> { @Override public LootAdditionModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) { Item addition = ForgeRegistries.ITEMS.getValue( new ResourceLocation(JSONUtils.getString(object, "addition"))); return new LootAdditionModifier(conditionsIn, addition); } @Override public JsonObject write(LootAdditionModifier instance) { JsonObject json = makeConditions(instance.conditions); json.addProperty("addition", ForgeRegistries.ITEMS.getKey(instance.addition).toString()); return json; } } } LootStructureAdditionModifier: public class LootStructureAdditionModifier extends LootModifier{ private final Item addition; protected LootStructureAdditionModifier(ILootCondition[] conditionsIn, Item addition) { super(conditionsIn); this.addition = addition; } @Nonnull @Override protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { // generatedLoot is the loot that would be dropped, if we wouldn't add or replace // anything! if(context.getRandom().nextFloat() > 1.0) { generatedLoot.add(new ItemStack(addition, 1)); } return generatedLoot; } public static class Serializer extends GlobalLootModifierSerializer<LootStructureAdditionModifier> { @Override public LootStructureAdditionModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) { Item addition = ForgeRegistries.ITEMS.getValue( new ResourceLocation(JSONUtils.getString(object, "addition"))); return new LootStructureAdditionModifier(conditionsIn, addition); } @Override public JsonObject write(LootStructureAdditionModifier instance) { JsonObject json = makeConditions(instance.conditions); json.addProperty("addition", ForgeRegistries.ITEMS.getKey(instance.addition).toString()); return json; } } } The global_loot_modifiers.json: { "replace": false, "entries": [ "mikesfancycontent:test" ] } And the test.json: { "conditions": [ { "condition": "minecraft:entity_properties", "entity": "this", "predicate": { "type": "minecraft:stray" } } ], "addition": "mikesfancycontent:frost_berries" } What do I have to change to make it work for mob drops. Thanks in advance.
March 28, 20223 yr this is not possible with GlobalLootModifiers, you can replace the LootTable of the Entity via a Datapack overwrite wrong information, ignore this post please Edited March 28, 20223 yr by Luis_ST
March 28, 20223 yr 4 hours ago, ChonkoTheGreat said: mikesfancycontent:test This is not the registry name of your loot modifier serializser(s) is it? Edited March 28, 20223 yr by Draco18s 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.
March 28, 20223 yr 3 hours ago, diesieben07 said: What are you talking about? just replacing the vanilla lootTable file via a Datapack, i mean data/minecraft/loot_tables/entities/entity_loot_table.json
March 28, 20223 yr They sure do, I made sure of it. Kinda surprised it isn't part of the test mod that went along with it in the Forge repo source, but whatever. I wrote it and tested it. So I know it works. 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.