Posted August 2, 20223 yr I made a Global Loot Modifier that doesn't seem to be working. I've probably messed up in the FireSwordInChest.java file. Here is FireSwordInChest.java: package com.juder.elementalswords.event.loot; import com.google.gson.JsonObject; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; import java.util.List; public class FireSwordFromChestAdditionModifier extends LootModifier { private final Item addition; protected FireSwordFromChestAdditionModifier(LootItemCondition[] conditionsIn, Item addition) { super(conditionsIn); this.addition = addition; } @Nonnull @Override protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { System.out.println("YO!"); generatedLoot.add(new ItemStack(addition, 1)); return generatedLoot; } public static class Serializer extends GlobalLootModifierSerializer<FireSwordFromChestAdditionModifier> { @Override public FireSwordFromChestAdditionModifier read(ResourceLocation name, JsonObject object, LootItemCondition[] conditionsIn) { Item addition = ForgeRegistries.ITEMS.getValue(new ResourceLocation(GsonHelper.getAsString(object, "addition"))); return new FireSwordFromChestAdditionModifier(conditionsIn, addition); } @Override public JsonObject write(FireSwordFromChestAdditionModifier instance) { JsonObject json = makeConditions(instance.conditions); json.addProperty("addition", ForgeRegistries.ITEMS.getKey(instance.addition).toString()); return json; } } } Any help would be appreciated. Please don't put anything from 1.16.5, 1.12.2, 1.14, 1.15, 1.0, or anything not 1.18.x or 1.19.x!
August 2, 20223 yr Nope, that class looks fine. Did you register the serializer? Did you add it to the forge/global_loot_modifiers.json list? 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.
August 2, 20223 yr If you are using 1.19 the GLM doesn't use a serializer anymore. It uses Codecs. You can see some examples in the forge tests: https://github.com/MinecraftForge/MinecraftForge/blob/1.19.x/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 4, 20223 yr Author I am using 1.18.2. Please don't put anything from 1.16.5, 1.12.2, 1.14, 1.15, 1.0, or anything not 1.18.x or 1.19.x!
August 4, 20223 yr Author I did not register the serializer. Thanks. Please don't put anything from 1.16.5, 1.12.2, 1.14, 1.15, 1.0, or anything not 1.18.x or 1.19.x!
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.