Siphalor / spiceoffabric

Another iteration of Spice of Life
https://modrinth.com/mod/spice-of-fabric
MIT License
8 stars 19 forks source link

getMaxUseTime infinite loop #49

Closed spoorn closed 2 years ago

spoorn commented 2 years ago

crash-2022-04-06_14.52.22-server.txt

Infinite loop when calling getMaxUseTime:

java.lang.StackOverflowError: Ticking entity
    at net.minecraft.class_1792.method_7881(class_1792.java:342)
    at net.minecraft.class_1799.method_7935(class_1799.java:538)
    at de.siphalor.spiceoffabric.util.MaxUseTimeCalculator.getMaxUseTime(MaxUseTimeCalculator.java:19)
    at net.minecraft.class_1799.handler$ehb000$getMaxUseTime(class_1799.java:11646)
    at net.minecraft.class_1799.method_7935(class_1799.java:538)
    at de.siphalor.spiceoffabric.util.MaxUseTimeCalculator.getMaxUseTime(MaxUseTimeCalculator.java:19)
    at net.minecraft.class_1799.handler$ehb000$getMaxUseTime(class_1799.java:11646)
    at net.minecraft.class_1799.method_7935(class_1799.java:538)
    at de.siphalor.spiceoffabric.util.MaxUseTimeCalculator.getMaxUseTime(MaxUseTimeCalculator.java:19)

I believe this is because this Mixin has a path that ends up calling itself again and again: https://github.com/Siphalor/spiceoffabric/blob/e2e50647f2d62306843e29f5e007a6fd0d4473ab/src/main/java/de/siphalor/spiceoffabric/mixin/MixinItemStack.java#L20

Might just need to change this to stack.getItem().getMaxUseTime():

https://github.com/Siphalor/spiceoffabric/blob/e2e50647f2d62306843e29f5e007a6fd0d4473ab/src/main/java/de/siphalor/spiceoffabric/util/MaxUseTimeCalculator.java#L19