Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Couldn't parse loot modifier error


Recommended Posts

I was wondering if anyone knows what is causing this error / how to fix it.

 

The full error:

Quote

[22:52:10] [Render thread/ERROR] [ne.mi.co.lo.LootModifierManager/]: Couldn't parse loot modifier enchantment_enchancements:midas_modifier
java.lang.NullPointerException: null
    at net.minecraftforge.common.loot.LootModifierManager.deserializeModifier(LootModifierManager.java:127) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at net.minecraftforge.common.loot.LootModifierManager.lambda$apply$0(LootModifierManager.java:115) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at java.util.ArrayList.forEach(ArrayList.java:1259) ~[?:1.8.0_271] {}
    at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:113) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:54) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at net.minecraft.client.resources.ReloadListener.lambda$reload$1(ReloadListener.java:14) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:670) ~[?:1.8.0_271] {}
    at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:646) ~[?:1.8.0_271] {}
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456) ~[?:1.8.0_271] {}
    at net.minecraft.resources.AsyncReloader.lambda$null$3(AsyncReloader.java:66) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.Minecraft.reloadDatapacks(Minecraft.java:1910) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:1762) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:1728) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_214443_e(WorldSelectionList.java:364) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_214438_a(WorldSelectionList.java:273) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screen.WorldSelectionList$Entry.mouseClicked(WorldSelectionList.java:225) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.widget.list.AbstractList.mouseClicked(AbstractList.java:309) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.INestedGuiEventHandler.mouseClicked(INestedGuiEventHandler.java:31) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:92) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:427) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:90) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:185) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:184) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
    at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {}
    at org.lwjgl.glfw.GLFW.glfwWaitEventsTimeout(GLFW.java:3174) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
    at com.mojang.blaze3d.systems.RenderSystem.limitDisplayFPS(RenderSystem.java:112) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1025) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271] {}
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_271] {}
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_271] {}
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_271] {}
    at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
    at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.5-36.0.22_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {}

 

The modifier JSON:

{
  "type": "enchantment_enhancements:midas_modifier",
  "conditions": [
    {
      "condition": "minecraft:match_tool",
      "predicate": {
        "enchantments": [
          {
            "enchantment": "enchantment_enhancements:midas",
            "levels": {
              "min": 1
            }
          }
        ]
      }
    }
  ],
  "curseItem": "minecraft:gold_nugget"
}

 

How I'm registering the modifier serializer:

package com.isensehostility.enchantment_enhancements.registries;

import com.isensehostility.enchantment_enhancements.EnchantmentEnhancements;
import com.isensehostility.enchantment_enhancements.loot_modifiers.MidasEnchantmentModifier;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistry;

@Mod.EventBusSubscriber(modid = EnchantmentEnhancements.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class SerializerRegistry {

   @SubscribeEvent
   public static void registerModifierSerializers(final RegistryEvent.Register< GlobalLootModifierSerializer<?>> event) {
      IForgeRegistry<GlobalLootModifierSerializer<?>> registry = event.getRegistry();
      register(registry, new MidasEnchantmentModifier.Serializer(), "midas_modifier");
   }

   private static void register(IForgeRegistry<GlobalLootModifierSerializer<?>> registry, GlobalLootModifierSerializer<?> serializer, String name) {
      registry.register(serializer.setRegistryName(EnchantmentEnhancements.locate(name)));
   }
}

 

The modifier itself:

package com.isensehostility.enchantment_enhancements.loot_modifiers;

import com.google.gson.JsonObject;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.conditions.ILootCondition;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
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 MidasEnchantmentModifier extends LootModifier {
    private final Item curseItem;

    public MidasEnchantmentModifier(ILootCondition[] conditionsIn, Item nugget) {
        super(conditionsIn);
        this.curseItem = nugget;
    }

    @Nonnull
    @Override
    public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
        generatedLoot.add(new ItemStack(curseItem));
        return generatedLoot;
    }

    public static class Serializer extends GlobalLootModifierSerializer<MidasEnchantmentModifier> {
        @Override
        public MidasEnchantmentModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) {
            Item gold_nugget = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getString(object, "curseItem")));
            return new MidasEnchantmentModifier(conditionsIn, gold_nugget);
        }

        @Override
        public JsonObject write(MidasEnchantmentModifier instance) {
            return null;
        }
    }
}

 

I thought I did everything correctly, but clearly that is not the case. Any help is appreciated.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.