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

[SOLVED][1.18] Loot Modifiers Require "type"... but using any known ones causes error


Recommended Posts

In 1.16, LootModifierManager#deserializeModifier read:

private IGlobalLootModifier deserializeModifier(ResourceLocation location, JsonElement element) {
        if (!element.isJsonObject()) return null;
        JsonObject object = element.getAsJsonObject();
        ILootCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), ILootCondition[].class);

        // For backward compatibility with the initial implementation, fall back to using the location as the type.
        // TODO: Remove fallback in 1.16
        ResourceLocation serializer = location;
        if (object.has("type"))
            serializer = new ResourceLocation(JSONUtils.getAsString(object, "type"));

        return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(serializer).read(location, object, lootConditions);

Note the if(object.has(type")){} block, which is lacking from the 1.18 version of the class:

private IGlobalLootModifier deserializeModifier(ResourceLocation location, JsonElement element) {
        if (!element.isJsonObject()) return null;
        JsonObject object = element.getAsJsonObject();
        LootItemCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), LootItemCondition[].class);

        ResourceLocation serializer = new ResourceLocation(GsonHelper.getAsString(object, "type"));

        return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(serializer).read(location, object, lootConditions);

So, the "value" tag is required now for loot modifiers... fine. I added this to my loot modifer json files when I kept getting NullPointerExceptions. But when I use a valid "value" tag I get:

[15:27:02] [Render thread/ERROR]: Couldn't parse loot modifier examplemod:add_structure_loot
java.lang.NullPointerException: Cannot invoke "net.minecraftforge.common.loot.GlobalLootModifierSerializer.read(net.minecraft.resources.ResourceLocation, com.google.gson.JsonObject, net.minecraft.world.level.storage.loot.predicates.LootItemCondition[])" because the return value of "net.minecraftforge.registries.IForgeRegistry.getValue(net.minecraft.resources.ResourceLocation)" is null
        at net.minecraftforge.common.loot.LootModifierManager.deserializeModifier(LootModifierManager.java:133) ~[forge-1.18-38.0.14_mapped_official_1.18-recomp.jar%2376%2382!:?]
        at net.minecraftforge.common.loot.LootModifierManager.lambda$apply$0(LootModifierManager.java:115) ~[forge-1.18-38.0.14_mapped_official_1.18-recomp.jar%2376%2382!:?]
        at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
        at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:113) ~[forge-1.18-38.0.14_mapped_official_1.18-recomp.jar%2376%2382!:?]
        at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:54) ~[forge-1.18-38.0.14_mapped_official_1.18-recomp.jar%2376%2382!:?]

My json file is:

  "type": "chest",
  "conditions": [
      "condition": "forge:loot_table_id",
      "loot_table_id": "examplemod:chests/modstructure"

I tried printing the contents of ForgeRegistries.LOOT_MODIFIER_SERIALIZERS to know which keys I can use, but got:

[15:26:13] [modloading-worker-0/INFO]: Printing LOOT_MODIFER_SERIALIZERS
[15:26:13] [modloading-worker-0/INFO]: Printed LOOT_MODIFER_SERIALIZERS

Is this a bug, given 1.18 is new, or am I not using these classes right?

Edited by izofar
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

"minecraft:chest" is not a valid loot modifier registry name.

I got this from the link above, which says:


Optional type of the loot table. Must be one of empty if the loot table does not generate any loot, entity for loot an entity drops, block for loot a block drops, chest for a treasure chest, fishing for a fishing loot table, gift for a cat or villager gift, advancement_reward if it's used as a reward for an advancement, barter for loot from bartering with piglins, command for /execute, selector for predicate= in selectors, advancement_entity for entity predicates in advancements or generic if none of the above apply.

If these are not the valid names, then what are?

Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

That is for loot tables. You are making a loot modifier.

You registered your GlobalLootModifierSerializer to the registry with a registry name. The "type" field tells the game which serializer to use.

Just noticed the first part. As for the second, thanks lad!

Link to comment
Share on other sites

  • izofar changed the title to [SOLVED][1.18] Loot Modifiers Require "type"... but using any known ones causes error

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.

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.


  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I've been trying for the past hour to get one of these Modpacks to work, and after running the Serverrun.bat it gets all the way through the process on both Modpacks before it gives me the following Error Message. Error: Could not find or load main class @libraries.net.minecraftforge.forge.1.18.1-39.0.22.win_args.txt Any help would be great!  
    • The game crashed while playing. please help I don't know how to. ---- Minecraft Crash Report ---- // Shall we play a game? Time: 1/29/22, 1:08 AM Description: Exception in server tick loop java.lang.NoSuchMethodError: 'net.minecraft.nbt.CompoundTag net.minecraft.world.level.block.entity.BlockEntity.save(net.minecraft.nbt.CompoundTag)'     at ht.treechop.common.block.ChoppedLogBlock$Entity.save(ChoppedLogBlock.java:291) ~[TreeChop-Mod-1.18.1.jar%2367!/:0.15.3] {re:classloading}     at ht.treechop.common.block.ChoppedLogBlock$Entity.m_5995_(ChoppedLogBlock.java:335) ~[TreeChop-Mod-1.18.1.jar%2367!/:0.15.3] {re:classloading}     at net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket.m_195642_(ClientboundBlockEntityDataPacket.java:21) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket.m_195640_(ClientboundBlockEntityDataPacket.java:25) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at ht.treechop.common.block.ChoppedLogBlock$Entity.getUpdatePacket(ChoppedLogBlock.java:328) ~[TreeChop-Mod-1.18.1.jar%2367!/:0.15.3] {re:classloading}     at ht.treechop.common.block.ChoppedLogBlock$Entity.m_183216_(ChoppedLogBlock.java:260) ~[TreeChop-Mod-1.18.1.jar%2367!/:0.15.3] {re:classloading}     at net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:562) ~[forge-1.18.1-39.0.62-universal.jar%2374!/:?] {re:classloading}     at net.minecraft.server.level.ServerPlayerGameMode.m_9280_(ServerPlayerGameMode.java:227) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:computing_frames,re:classloading}     at net.minecraft.server.level.ServerPlayerGameMode.m_9286_(ServerPlayerGameMode.java:217) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:computing_frames,re:classloading}     at net.minecraft.server.level.ServerPlayerGameMode.m_7391_(ServerPlayerGameMode.java:187) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:computing_frames,re:classloading}     at net.minecraft.server.network.ServerGamePacketListenerImpl.m_7502_(ServerGamePacketListenerImpl.java:945) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.m_5797_(ServerboundPlayerActionPacket.java:34) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.m_5797_(ServerboundPlayerActionPacket.java:8) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at net.minecraft.network.protocol.PacketUtils.m_131356_(PacketUtils.java:21) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at net.minecraft.server.TickTask.run(TickTask.java:18) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:classloading}     at net.minecraft.util.thread.BlockableEventLoop.m_6367_(BlockableEventLoop.java:151) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B}     at net.minecraft.util.thread.ReentrantBlockableEventLoop.m_6367_(ReentrantBlockableEventLoop.java:23) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,re:computing_frames,re:classloading}     at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:765) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:161) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at net.minecraft.util.thread.BlockableEventLoop.m_7245_(BlockableEventLoop.java:125) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.m_129961_(MinecraftServer.java:748) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_7245_(MinecraftServer.java:742) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at net.minecraft.util.thread.BlockableEventLoop.m_18699_(BlockableEventLoop.java:110) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.m_130012_(MinecraftServer.java:727) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:672) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_177918_(MinecraftServer.java:258) ~[client-1.18.1-20211210.034407-srg.jar%2370!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.18.1     Minecraft Version ID: 1.18.1     Operating System: Windows 10 (amd64) version 10.0     Java Version: 17.0.1, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 2163132464 bytes (2062 MiB) / 6643777536 bytes (6336 MiB) up to 8589934592 bytes (8192 MiB)     CPUs: 8     Processor Vendor: GenuineIntel     Processor Name: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz     Identifier: Intel64 Family 6 Model 142 Stepping 11     Microarchitecture: whiskey Lake     Frequency (GHz): 1.99     Number of physical packages: 1     Number of physical CPUs: 4     Number of logical CPUs: 8     Graphics card #0 name: Intel(R) UHD Graphics 620     Graphics card #0 vendor: Intel Corporation (0x8086)     Graphics card #0 VRAM (MB): 1024.00     Graphics card #0 deviceId: 0x3ea0     Graphics card #0 versionInfo: DriverVersion=     Memory slot #0 capacity (MB): 8192.00     Memory slot #0 clockSpeed (GHz): 2.40     Memory slot #0 type: DDR4     Memory slot #1 capacity (MB): 8192.00     Memory slot #1 clockSpeed (GHz): 2.40     Memory slot #1 type: DDR4     Virtual memory max (MB): 20670.30     Virtual memory used (MB): 17701.50     Swap memory total (MB): 4496.57     Swap memory used (MB): 717.27     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx8G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Server Running: true     Player Count: 1 / 8; [ServerPlayer['rocio12barcenas'/187, l='ServerLevel[New World]', x=82.38, y=75.00, z=-249.35]]     Data Packs: vanilla, mod:forge, mod:sereneseasons (incompatible), mod:mna (incompatible), mod:treechop (incompatible), mod:terrablender, mod:apotheosis (incompatible), mod:cfm, mod:jei, mod:bumblecore, mod:byg (incompatible), mod:torohealth (incompatible), mod:curios, mod:xaerominimap, mod:geckolib3 (incompatible), mod:xaeroworldmap, mod:placebo (incompatible), mod:dramaticdoors, mod:travelersbackpack, mod:foodsicles     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'forge'; Server brand changed to 'forge'     ModLauncher: 9.1.0+9.1.0+main.6690ee51     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:           mixin PLUGINSERVICE           eventbus PLUGINSERVICE           object_holder_definalize PLUGINSERVICE           runtime_enum_extender PLUGINSERVICE           capability_token_subclass PLUGINSERVICE           accesstransformer PLUGINSERVICE           runtimedistcleaner PLUGINSERVICE           mixin TRANSFORMATIONSERVICE           fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         javafml@null     Mod List:          client-1.18.1-20211210.034407-srg.jar             |Minecraft                     |minecraft                     |1.18.1              |DONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f         Serene-Seasons-Mod-1.18.1.jar                     |Serene Seasons                |sereneseasons                 |1.18.1-     |DONE      |Manifest: NOSIGNATURE         Mana-and-Artifice-Mod-1.18.1.jar                  |Mana and Artifice             |mna                           |             |DONE      |Manifest: NOSIGNATURE         TreeChop-Mod-1.18.1.jar                           |HT's TreeChop                 |treechop                      |0.15.3              |DONE      |Manifest: NOSIGNATURE         TerraBlender-forge-1.18.1-            |TerraBlender                  |terrablender                  |1.18.1-     |DONE      |Manifest: NOSIGNATURE         Apotheosis-Mod-1.18.1.jar                         |Apotheosis                    |apotheosis                    |5.2.0               |DONE      |Manifest: NOSIGNATURE         MrCrayfishs-Furniture-Mod-1.18.1.jar              |MrCrayfish's Furniture Mod    |cfm                           |7.0.0-pre28         |DONE      |Manifest: NOSIGNATURE         jei-1.18.1-                           |Just Enough Items             |jei                           |            |DONE      |Manifest: NOSIGNATURE         bumblecore-1.18.1-1.0.4.jar                       |Bumblecore                    |bumblecore                    |1.18.1-1.0.4        |DONE      |Manifest: NOSIGNATURE         Oh+The+Biomes+You'll+Go-forge-1.18.1-  |Oh The Biomes You'll Go       |byg                           |             |DONE      |Manifest: NOSIGNATURE         forge-1.18.1-39.0.62-universal.jar                |Forge                         |forge                         |39.0.62             |DONE      |Manifest: 84:ce:76:e8:45:35:e4:0e:63:86:df:47:59:80:0f:67:6c:c1:5f:6e:5f:4d:b3:54:47:1a:9f:7f:ed:5e:f2:90         torohealth-1.18-forge-2.jar                       |ToroHealth                    |torohealth                    |1.18-forge-2        |DONE      |Manifest: NOSIGNATURE         Curios-API-1.18.1.jar                             |Curios API                    |curios                        |1.18.1-      |DONE      |Manifest: NOSIGNATURE         Xaeros_Minimap_22.1.0_Forge_1.18.jar              |Xaero's Minimap               |xaerominimap                  |22.1.0              |DONE      |Manifest: NOSIGNATURE         geckolib-1.18-forge-3.0.9.jar                     |GeckoLib                      |geckolib3                     |3.0.9               |DONE      |Manifest: NOSIGNATURE         XaerosWorldMap_1.20.0_Forge_1.18.jar              |Xaero's World Map             |xaeroworldmap                 |1.20.0              |DONE      |Manifest: NOSIGNATURE         Place2bo-1.18.1-6.0.5.jar                          |Placebo                       |placebo                       |6.0.5               |DONE      |Manifest: NOSIGNATURE         Dramatic-Doors-Mod-1.18.1.jar                     |Dramatic Doors                |dramaticdoors                 |1.18.1-1.5.0        |DONE      |Manifest: NOSIGNATURE         TravelersBackpack-1.18.1-7.0.1.jar                |Traveler's Backpack           |travelersbackpack             |7.0.1               |DONE      |Manifest: NOSIGNATURE         foodsicles-1.18.1-1.0.4.jar                       |Foodsicles                    |foodsicles                    |1.18.1-1.0.4        |DONE      |Manifest: NOSIGNATURE     Crash Report UUID: d060c158-744d-48bd-ba52-bf8d49f5f8d2     FML: 39.0     Forge: net.minecraftforge:39.0.6
    • Hi guys! I currently have a project that I've been developing in a 'vanilla' environment that I'm actually looking to transfer over to Forge, simply because of how much better the experience would be using Forge. Before starting on this Forge mod, I was planning ahead and was looking at options for proxies, of which I would greatly like to use Velocity. In their docs and by asking around their Discord, they don't support support versions of Forge of 1.13 or later because of changes in the "handshake protocol". But I also really don't want to use an unsupported version of Forge, such as 1.12.2, to be able to use a proxy. I was pointed in the direction of potentially making my own client-side mod to allow Forge to be compatible with an updated proxy, such as Velocity. When asking for a direction for achieving this, I was told to have a look at how the Forge server implements logins and that the discrepancy might be with how modified the handshake protocol is. This sounds like quite the challenge to me and I'm completely up for trying to accomplish it. So for the sake of planning ahead and having a rough idea of how I could accomplish that when the time comes to work on it, has anyone else had experience with trying to achieve this? I appreciate any help or direction offered! Thanks! 
    • Been trying to set up a server for myself and a few friends through BisectHosting. I ended up replicating the server on my own computer to see if the issue persisted (if it was on bisect's end) and it was still there. Every time a player tries to connect to the server they start connecting but after only around 2 seconds the player is disconnected with the error message Payload size exceeds 1048576 bytes.  Upon inspection of the server debug file, the player always disconnects while fmlhandshake ticking packet info is being sent, and I have repeatedly made sure the mods and their configs are identical. I tried to get RandomPatches to increase the max allowed byte size, as the default seems to be 32767, but either something is wrong with it or some other mod is limiting the packet size limit.     Server Debug: https://pastebin.com/xZLbtdQB (only includes portions from after the server launched as I couldn't upload the whole file) Server Log: https://pastebin.com/yrJ3tNaW (similarly only after server launched (hence the weird say commands) Client Log: https://pastebin.com/inSzZV96 (whole thing for once) Modlist: https://pastebin.com/Qvurg45j (All but Optifine and BetterFoliage are present on the server as they have caused issues during startup)   Honestly stumped on how to fix this, been working on it for 10 hours across two days to no avail.
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

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