9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 11:29:17 +00:00

fix(block): 修复作物生长问题

This commit is contained in:
jhqwqmc
2025-03-28 12:30:41 +08:00
parent b248c265dc
commit 2c449404b2

View File

@@ -82,11 +82,9 @@ public class CropBlockBehavior extends BushBlockBehavior {
if (getRawBrightness(level, pos) >= minGrowLight) {
int age = this.getAge(state);
float randomFloat = RandomUtils.generateRandomFloat(0, 1);
System.out.println("age: " + age + "ageProperty.max: " + this.ageProperty.max + " -> " + (age < this.ageProperty.max));
System.out.println("randomFloat: " + randomFloat + "growSpeed: " + this.growSpeed + " -> " + (randomFloat < this.growSpeed));
if (age < this.ageProperty.max && randomFloat >= this.growSpeed) {
if (age < this.ageProperty.max && randomFloat < 1.0 / Math.floor(25.0 / this.growSpeed + 1.0)) {
System.out.println("grow");
Reflections.method$Level$setBlock.invoke(level, pos, getStateForAge(state, age + 1), UpdateOption.UPDATE_NONE.flags());
Reflections.method$Level$setBlock.invoke(level, pos, getStateForAge(state, age + 1), UpdateOption.UPDATE_ALL.flags());
}
}
}