Fix infested leaves. Close #64

This commit is contained in:
thedarkcolour 2024-04-03 20:51:08 -07:00
parent 4b31bcd0d2
commit ad9e0dd04e
No known key found for this signature in database
GPG Key ID: 6599A8E0516C8F38
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,6 @@
## Ex Deorum 2.3
- Fixed infested leaves not dropping string with a Crook
## Ex Deorum 2.2
- Fixed hammers and crooks not working

View File

@ -41,6 +41,8 @@ import thedarkcolour.exdeorum.registry.EBlocks;
public class InfestedLeavesBlockEntity extends EBlockEntity {
// progress is a short between 0 and 16000 (why? because that's what the shader uses, also avoids float errors)
public static final short MAX_PROGRESS = 16000;
// leaves only spread at 60% infestation and above
public static final short SPREAD_THRESHOLD = (MAX_PROGRESS * 3) / 5;
// 0.005 * 16000 = 80
public static final short PROGRESS_INTERVAL = 80;
public static final int SPREAD_INTERVAL = 40;
@ -121,7 +123,7 @@ public class InfestedLeavesBlockEntity extends EBlockEntity {
this.mimic = Blocks.OAK_LEAVES.defaultBlockState();
}
nbt.put("mimic", NbtUtils.writeBlockState(this.mimic));
nbt.putFloat("progress", this.progress);
nbt.putShort("progress", this.progress);
}
public int getProgress() {
@ -152,13 +154,13 @@ public class InfestedLeavesBlockEntity extends EBlockEntity {
if (leaves.progress < MAX_PROGRESS) {
leaves.progress = (short) Math.min(MAX_PROGRESS, leaves.progress + PROGRESS_INTERVAL);
if (leaves.progress == 1.0f) {
if (leaves.progress == MAX_PROGRESS) {
level.setBlock(pos, state.setValue(InfestedLeavesBlock.FULLY_INFESTED, true), 1);
}
}
// If the leave is infested enough, advance the spread timer
if (!level.isClientSide && leaves.progress > 0.6f) {
if (!level.isClientSide && leaves.progress >= SPREAD_THRESHOLD) {
++leaves.spreadTimer;
// Attempt to spread and reset the timer