From ad9e0dd04e6e08d7011d32c46bed792cd8e4da09 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Wed, 3 Apr 2024 20:51:08 -0700 Subject: [PATCH] Fix infested leaves. Close #64 --- changelog.md | 3 +++ .../exdeorum/blockentity/InfestedLeavesBlockEntity.java | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 2d0af419..cfcab079 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java index 188e9614..3d80342e 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/InfestedLeavesBlockEntity.java @@ -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