Tinkers Construct

Tinkers Construct

160M Downloads

Cannot disable tool parts for specific materials as null value gives an error

Insane96 opened this issue ยท 3 comments

commented

Minecraft Version

1.18.2

Forge Version

40.1.51

Mantle Version

1.9.28

Tinkers' Construct Version

3.5.1.32

Describe your issue

Using datapacks to remove tool parts from a material (e.g. disabling wooden heads) will fail as the datapack fails to load when there's a null value.

This was tested with a datapack containing a single file (wood.json) in data/tconstruct/tinkering/materials/stats
The file content was as follows

{
  "stats": {
    "tconstruct:extra": {},
    "tconstruct:handle": {
      "durability": 1.0,
      "miningSpeed": 1.0,
      "attackSpeed": 1.0,
      "attackDamage": 1.0
    },
    "tconstruct:head": null
  }
}

Resulting is an error

[20:08:47] [Render thread/ERROR]: Couldn't parse data file tconstruct:wood from tconstruct:tinkering/materials/stats/wood.json in data pack test
com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonNull
	at com.google.gson.internal.bind.TypeAdapters$33$1.read(TypeAdapters.java:869) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:187) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.Gson.fromJson(Gson.java:963) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.Gson.fromJson(Gson.java:1034) ~[gson-2.8.9.jar%2334!/:?]
	at com.google.gson.Gson.fromJson(Gson.java:1006) ~[gson-2.8.9.jar%2334!/:?]
	at slimeknights.tconstruct.library.materials.stats.MaterialStatsManager.parse(MaterialStatsManager.java:176) ~[TConstruct-1.18.2-3.5.1.31.jar%2353!/:1.18.2-3.5.1.31]
	at slimeknights.tconstruct.library.materials.stats.MaterialStatsManager.parse(MaterialStatsManager.java:43) ~[TConstruct-1.18.2-3.5.1.31.jar%2353!/:1.18.2-3.5.1.31]
	at slimeknights.mantle.data.MergingJsonDataLoader.m_6213_(MergingJsonDataLoader.java:76) ~[Mantle-1.18.2-1.9.27.jar%2352!/:1.18.2-1.9.27]
	at slimeknights.tconstruct.library.materials.stats.MaterialStatsManager.m_6213_(MaterialStatsManager.java:210) ~[TConstruct-1.18.2-3.5.1.31.jar%2353!/:1.18.2-3.5.1.31]
	at net.minecraft.server.packs.resources.ResourceManagerReloadListener.m_10759_(ResourceManagerReloadListener.java:15) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787) ~[?:?]
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
	at net.minecraft.server.packs.resources.SimpleReloadInstance.m_143940_(SimpleReloadInstance.java:69) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_6367_(BlockableEventLoop.java:157) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.m_6367_(ReentrantBlockableEventLoop.java:23) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_7245_(BlockableEventLoop.java:131) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_18701_(BlockableEventLoop.java:140) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.Minecraft.m_205125_(Minecraft.java:2080) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.Minecraft.doLoadLevel(Minecraft.java:1907) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.Minecraft.m_91200_(Minecraft.java:1871) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.m_101744_(WorldSelectionList.java:473) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.m_101704_(WorldSelectionList.java:330) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.m_6375_(WorldSelectionList.java:257) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.gui.components.AbstractSelectionList.m_6375_(AbstractSelectionList.java:323) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.gui.components.events.ContainerEventHandler.m_6375_(ContainerEventHandler.java:27) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.MouseHandler.m_168084_(MouseHandler.java:88) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.gui.screens.Screen.m_96579_(Screen.java:528) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.MouseHandler.m_91530_(MouseHandler.java:85) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.MouseHandler.m_168091_(MouseHandler.java:185) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:103) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.MouseHandler.m_91565_(MouseHandler.java:184) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar%2347!/:build 10]
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar%2343!/:build 10]
	at org.lwjgl.glfw.GLFW.glfwWaitEventsTimeout(GLFW.java:3174) ~[lwjgl-glfw-3.2.2.jar%2347!/:build 10]
	at com.mojang.blaze3d.systems.RenderSystem.m_69830_(RenderSystem.java:222) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1069) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:663) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at net.minecraft.client.main.Main.main(Main.java:205) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:31) ~[fmlloader-1.18.2-40.1.52.jar%2316!/:?]
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.3.jar%235!/:?]
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?]

Crash Report

No response

Other mods

None

Tried reproducing with just Tinkers?

Yes

Performance Enchancers

None of the above

Searched for known issues?

I did not search

commented

That JSON will never be able to disable a material, that would entirely break addons adding their own stat types. The whole reason it merges with lower levels is so each mod can add their own stats. to materials without conflicting.

The proper way to disable it is setting it to null, e.g.

{
  "tconstruct:head": null
}

If that is not working, please say so on the issue.

commented

Updated the issue

commented

3.4.2.40 adds a way to remove specific tool stat types for a material.