aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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();
}
}