BCLib

BCLib

31M Downloads

[Bug] Putting item in anvil causes game to crash, 'material' is 'null' (1.21)

FartThePart opened this issue ยท 15 comments

commented

What happened?

When me and my other friend were trying out mods and trying to see if everything worked well, whenever we placed any item into the anvil it crashes every time. We checked if it was other mods making it that way but it would always lead to BCLib being the problem.

BCLib

21.0.3

Fabric API

0.100.4+1.21

Fabric Loader

1.0.1

Minecraft

1.20.4

Relevant log output

The game crashed whilst container click
Error: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1799.method_7947()" because "material" is null

Other Mods

No response

commented

Same issue here, pulled this directly from the crashlog.
Seems to be related to BCLib recipes for anvilrecipe.class

Wish this would get fixed soon, as it is such a gamebreaking bug. :(

[23:40:58] [Render thread/ERROR]: Reported exception thrown!
net.minecraft.class_148: Container click
	at net.minecraft.class_437.method_25412(class_437.java:436) ~[client-intermediary.jar:?]
	at net.minecraft.class_312.method_1601(class_312.java:109) ~[client-intermediary.jar:?]
	at net.minecraft.class_312.method_22686(class_312.java:196) ~[client-intermediary.jar:?]
	at net.minecraft.class_1255.execute(class_1255.java:108) ~[client-intermediary.jar:?]
	at net.minecraft.class_312.method_22684(class_312.java:196) ~[client-intermediary.jar:?]
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:43) ~[lwjgl-glfw-3.3.3.jar:?]
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.3.3.jar:?]
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3438) ~[lwjgl-glfw-3.3.3.jar:?]
	at com.mojang.blaze3d.systems.RenderSystem.pollEvents(RenderSystem.java:150) ~[client-intermediary.jar:?]
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:168) ~[client-intermediary.jar:?]
	at net.minecraft.class_1041.method_15998(class_1041.java:303) ~[client-intermediary.jar:?]
	at net.minecraft.class_310.method_1523(class_310.java:1307) ~[client-intermediary.jar:?]
	at net.minecraft.class_310.method_1514(class_310.java:882) [client-intermediary.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:256) [client-intermediary.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.15.11.jar:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1799.method_7947()" because "material" is null
	at org.betterx.bclib.recipes.AnvilRecipe.matches(AnvilRecipe.java:161) ~[bclib-21.0.5.jar:?]
	at org.betterx.bclib.recipes.AnvilRecipe.matches(AnvilRecipe.java:99) ~[bclib-21.0.5.jar:?]
	at org.betterx.bclib.recipes.AnvilRecipe.method_8115(AnvilRecipe.java:45) ~[bclib-21.0.5.jar:?]
	at net.minecraft.class_1863.method_42297(class_1863.java:106) ~[client-intermediary.jar:?]
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) ~[?:?]
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024) ~[?:?]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?]
	at net.minecraft.class_1863.method_17877(class_1863.java:108) ~[client-intermediary.jar:?]
	at net.minecraft.class_1706.handler$zek000$bclib$bcl_updateOutput(class_1706.java:631) ~[client-intermediary.jar:?]
	at net.minecraft.class_1706.method_24928(class_1706.java) ~[client-intermediary.jar:?]
	at net.minecraft.class_1706.method_7625(class_1706.java:355) ~[client-intermediary.jar:?]
	at net.minecraft.class_471.method_2403(class_471.java:85) ~[client-intermediary.jar:?]
	at net.minecraft.class_342.method_1874(class_342.java:154) ~[client-intermediary.jar:?]
	at net.minecraft.class_342.method_1883(class_342.java:262) ~[client-intermediary.jar:?]
	at net.minecraft.class_342.method_1872(class_342.java:275) ~[client-intermediary.jar:?]
	at net.minecraft.class_342.method_1852(class_342.java:102) ~[client-intermediary.jar:?]
	at net.minecraft.class_471.method_7635(class_471.java:140) ~[client-intermediary.jar:?]
	at net.minecraft.class_1703.method_34246(class_1703.java:219) ~[client-intermediary.jar:?]
	at net.minecraft.class_1703.method_7623(class_1703.java:176) ~[client-intermediary.jar:?]
	at net.minecraft.class_1703.method_7609(class_1703.java:589) ~[client-intermediary.jar:?]
	at net.minecraft.class_4861.method_7609(class_4861.java:103) ~[client-intermediary.jar:?]
	at net.minecraft.class_4861$3.method_5431(class_4861.java:96) ~[client-intermediary.jar:?]
	at net.minecraft.class_1277.redirect$cbg000$fabric-transfer-api-v1$fabric_redirectMarkDirty(class_1277.java:543) ~[client-intermediary.jar:?]
	at net.minecraft.class_1277.method_5447(class_1277.java:142) ~[client-intermediary.jar:?]
	at net.minecraft.class_1735.method_7673(class_1735.java:75) ~[client-intermediary.jar:?]
	at net.minecraft.class_1735.method_48931(class_1735.java:66) ~[client-intermediary.jar:?]
	at net.minecraft.class_1735.method_53512(class_1735.java:63) ~[client-intermediary.jar:?]
	at net.minecraft.class_1735.method_32755(class_1735.java:160) ~[client-intermediary.jar:?]
	at net.minecraft.class_1703.method_30010(class_1703.java:412) ~[client-intermediary.jar:?]
	at net.minecraft.class_1703.method_30010(class_1703.java:342) ~[client-intermediary.jar:?]
	at net.minecraft.class_1703.method_7593(class_1703.java:294) ~[client-intermediary.jar:?]
	at net.minecraft.class_636.method_2906(class_636.java:448) ~[client-intermediary.jar:?]
	at net.minecraft.class_465.method_2383(class_465.java:557) ~[client-intermediary.jar:?]
	at net.minecraft.class_465.method_25406(class_465.java:512) ~[client-intermediary.jar:?]
	at net.minecraft.class_312.method_1605(class_312.java:109) ~[client-intermediary.jar:?]
	at net.minecraft.class_437.method_25412(class_437.java:431) ~[client-intermediary.jar:?]
	... 16 more
commented

same issue

commented

same issue

commented

same issue

commented

+1 to this

commented

Same thing going on for me
`

HEADLINE
[16:54:08] [Render thread/ERROR]:
Reported exception thrown!
net.minecraft.class_148: Container click
at net.minecraft.class_437.method_25412(class_437.java:436) ~[client-intermediary.jar:?]
at net.minecraft.class_312.method_1601(class_312.java:109) ~[client-intermediary.jar:?]
at net.minecraft.class_312.method_22686(class_312.java:196) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.execute(class_1255.java:108) ~[client-intermediary.jar:?]
at net.minecraft.class_312.method_22684(class_312.java:196) ~[client-intermediary.jar:?]
at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:43) ~[lwjgl-glfw-3.3.3.jar:?]
at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.3.3.jar:?]
at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3438) ~[lwjgl-glfw-3.3.3.jar:?]
at com.mojang.blaze3d.systems.RenderSystem.pollEvents(RenderSystem.java:150) ~[client-intermediary.jar:?]
at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:168) ~[client-intermediary.jar:?]
at net.minecraft.class_1041.method_15998(class_1041.java:303) ~[client-intermediary.jar:?]
at net.minecraft.class_310.method_1523(class_310.java:1307) ~[client-intermediary.jar:?]
at net.minecraft.class_310.method_1514(class_310.java:882) [client-intermediary.jar:?]
at net.minecraft.client.main.Main.main(Main.java:256) [client-intermediary.jar:?]
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) [fabric-loader-0.15.11.jar:?]
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.15.11.jar:?]
at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.15.11.jar:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1799.method_7947()" because "material" is null
at org.betterx.bclib.recipes.AnvilRecipe.matches(AnvilRecipe.java:161) ~[bclib-21.0.5.jar:?]
at org.betterx.bclib.recipes.AnvilRecipe.matches(AnvilRecipe.java:99) ~[bclib-21.0.5.jar:?]
at org.betterx.bclib.recipes.AnvilRecipe.method_8115(AnvilRecipe.java:45) ~[bclib-21.0.5.jar:?]
at net.minecraft.class_1863.method_42297(class_1863.java:106) ~[client-intermediary.jar:?]
at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[?:?]
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[?:?]
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[?:?]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[?:?]
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[?:?]
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[?:?]
at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source) ~[?:?]
at net.minecraft.class_1863.method_17877(class_1863.java:108) ~[client-intermediary.jar:?]
at net.minecraft.class_1706.handler$zfc000$bclib$bcl_updateOutput(class_1706.java:631) ~[client-intermediary.jar:?]
at net.minecraft.class_1706.method_24928(class_1706.java) ~[client-intermediary.jar:?]
at net.minecraft.class_1706.method_7625(class_1706.java:355) ~[client-intermediary.jar:?]

`
commented

I'm having the same problem too, has anyone solved it yet? I don't want to give up on Better Nether and Better End...I can at least not try to enchant anything for now.

commented

I don't want to give up on Better Nether and Better End

You can always use BCLib on an older version of Minecraft where this issue isn't present.

commented

True

commented

+1 same issue

commented

This issue seems to stem from this line in code, where the item queried from the recipe is null if not present:

return c.hasIngerdient() ? c.getIngredient() : null;

I don't know how the input ingredients are generated or created, but this should be handled explicitly
Also I just noticed it has a typo

commented

I'm pretty sure I have the solution. In AnvilRecipe at around like 160 in the matches method instead of expecting the material to not be null and calling getCount(), check if it's null first. Smt like this:

public boolean matches(AnvilRecipeInput craftingInventory) {
    ItemStack hammer = getHammer(craftingInventory);
    if (hammer == null) {
        return false;
    }
    ItemStack material = getIngredient(craftingInventory);
    if (material == null) {
    	return false;
    }
    int materialCount = material.getCount();

    return this.input.test(material) && materialCount >= this.inputCount && hammer.is(allowedTools);
}

I'm not really sure what this whole AnvilRecipe class is for so I'm not 100% sure that returning false when the "material" is null is the correct answer but the test method seems to return anyway when the passed in stack is null so it's probably finee.
I haven't tested if this works but from the crash log I'd guess that this is the issue.

commented

New update and anvils still arent fixed, Really hope they fix this issue soon as its killing my livestream playthrough

commented

New update and anvils still arent fixed, Really hope they fix this issue soon as its killing my livestream playthrough

You can temporary disabled BetterEnd mod. Since it introduce hammer.
And your anvil can work properly.

commented

This should be fixed with BCLib 21.0.7 and up