aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2023-09-12 07:46:02 +0100
committerGitHub <noreply@github.com>2023-09-12 08:46:02 +0200
commit1cbf0d27fa1f9b56aaa67fc3b5e2723100fd64ef (patch)
tree7114ac44c9ff65f6d1cc0c3bfe90580338f8d1e9 /src
parentce52a805da551f4cef1b14beab58821887e349b9 (diff)
downloadNotEnoughUpdates-1cbf0d27fa1f9b56aaa67fc3b5e2723100fd64ef.tar.gz
NotEnoughUpdates-1cbf0d27fa1f9b56aaa67fc3b5e2723100fd64ef.tar.bz2
NotEnoughUpdates-1cbf0d27fa1f9b56aaa67fc3b5e2723100fd64ef.zip
Fix Item Cooldown Inconsistency with Treecap (#824)
Improved block change detection with wood
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
index 2253ca4a..01448a06 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
@@ -23,6 +23,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
+import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.util.BlockPos;
@@ -67,10 +68,24 @@ public class ItemCooldowns {
private static long bonzoMaskCooldown = -1;
private static long spiritMaskCooldown = -1;
- public static TreeMap<Long, BlockPos> blocksClicked = new TreeMap<>();
+ public static TreeMap<Long, BlockData> blocksClicked = new TreeMap<>();
private static int tickCounter = 0;
+ /**
+ * Class to store the block state at a position, the moment the position is passed
+ */
+ public static class BlockData {
+
+ public BlockPos blockPos;
+ public IBlockState blockState;
+
+ public BlockData(BlockPos pos) {
+ this.blockPos = pos;
+ this.blockState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
+ }
+ }
+
enum Item {
PICKAXES,
BONZO_MASK,
@@ -144,15 +159,25 @@ public class ItemCooldowns {
public static void blockClicked(BlockPos pos) {
long currentTime = System.currentTimeMillis();
- blocksClicked.put(currentTime, pos);
+ blocksClicked.put(currentTime, new BlockData(pos));
}
public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
BlockPos pos = packetIn.getBlockPosition();
+ checkForBlockChange(pos, packetIn.blockState);
+ }
+
+ public static void checkForBlockChange(BlockPos pos, IBlockState blockState) {
+ BlockData oldBlockData = null;
+
+ for (BlockData value : blocksClicked.values()) {
+ if (value.blockPos.equals(pos)) oldBlockData = value;
+ }
- if (blocksClicked.containsValue(pos)) {
- IBlockState oldState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
- if (oldState.getBlock() != packetIn.getBlockState().getBlock()) {
+ if (oldBlockData != null) {
+ IBlockState oldState = oldBlockData.blockState;
+ if ((oldState.getBlock() == Blocks.log || oldState.getBlock() == Blocks.log2) &&
+ blockState.getBlock() == Blocks.air) {
onBlockMined();
}
}