Corn Delight [Fabric/Quilt]

Corn Delight [Fabric/Quilt]

71.4k Downloads

Crash due to age growth ticking past limit

emmatyping opened this issue ยท 1 comments

commented

Hi! Thank you for this mod, it seems that in this code:

if (age < this.getMaxAge()) {
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
world.setBlockState(pos, this.withAge(age + 1), 2);
}
}
}
if (state.get(this.getUpperProperty()))
return;
if (age >= this.getGrowUpperAge()) {
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
if (this.getDefaultState().canPlaceAt(world, pos.up()) && world.isAir(pos.up())) {
world.setBlockState(pos, this.withAge(age + 1), 2);
line 85 does not verify that age + 1 is valid like on line 74, and causes a crash. An example trace-back:

java.lang.IllegalArgumentException: Cannot set property class_2758{name=age, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7]} to 8 on Block{corndelight:corn_crop}, it is not an allowed value
        at net.minecraft.class_2688.method_11657(class_2688.java:130)
        at net.minecraft.class_2302.method_9828(class_2302.java:66)
        at krelox.corndelight.block.CornCropBlock.method_9514(CornCropBlock.java:85)
        at net.minecraft.class_4970$class_4971.method_26199(class_4970.java:1117)
        at net.minecraft.class_3218.method_18203(class_3218.java:523)
        at net.minecraft.class_3215.method_14161(class_3215.java:382)
        at net.minecraft.class_3215.method_12127(class_3215.java:326)
        at net.minecraft.class_3218.method_18765(class_3218.java:333)
        at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:897)
        at net.minecraft.class_3176.method_3813(class_3176.java:283)
        at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:824)
        at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:671)
        at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265)
        at java.base/java.lang.Thread.run(Unknown Source)

I don't really understand the grow upper age part, so I don't want to suggest a change but hopefully this is enough info to fix the cause of the crash. For now I've removed the crops so they don't tick.

commented

Can you give me steps for reproducing this issue in-game please?