From 8aad7fb44b771d0d332806a07f958124c08014ed Mon Sep 17 00:00:00 2001 From: abel1502 Date: Mon, 23 Sep 2024 18:21:57 +0300 Subject: [PATCH] Fix conveyor grabber delay --- .../tileentity/network/TileEntityCraneGrabber.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java index 728ff2e67..b5bf3c2d0 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java @@ -32,6 +32,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP public boolean isWhitelist = false; public ModulePatternMatcher matcher; + public long lastGrabbedTick = 0; public TileEntityCraneGrabber() { super(11); @@ -63,7 +64,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP } } - if(worldObj.getTotalWorldTime() % delay == 0 && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { + if(worldObj.getTotalWorldTime() >= lastGrabbedTick + delay && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { int amount = 1; if(slots[9] != null && slots[9].getItem() == ModItems.upgrade_stack) { @@ -111,6 +112,8 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP boolean match = this.matchesFilter(stack); if(this.isWhitelist && !match || !this.isWhitelist && match) continue; + lastGrabbedTick = worldObj.getTotalWorldTime(); + ItemStack copy = stack.copy(); int toAdd = Math.min(stack.stackSize, amount); copy.stackSize = toAdd; @@ -132,8 +135,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP NBTTagCompound data = new NBTTagCompound(); - data.setBoolean("isWhitelist", isWhitelist); - this.matcher.writeToNBT(data); + this.writeToNBT(data); this.networkPack(data, 15); } } @@ -141,9 +143,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP public void networkUnpack(NBTTagCompound nbt) { super.networkUnpack(nbt); - this.isWhitelist = nbt.getBoolean("isWhitelist"); - this.matcher.modes = new String[this.matcher.modes.length]; - this.matcher.readFromNBT(nbt); + this.readFromNBT(nbt); } public boolean matchesFilter(ItemStack stack) { @@ -175,6 +175,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP super.readFromNBT(nbt); this.isWhitelist = nbt.getBoolean("isWhitelist"); this.matcher.readFromNBT(nbt); + this.lastGrabbedTick = nbt.getLong("lastGrabbedTick"); } @Override @@ -182,6 +183,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP super.writeToNBT(nbt); nbt.setBoolean("isWhitelist", this.isWhitelist); this.matcher.writeToNBT(nbt); + nbt.setLong("lastGrabbedTick", lastGrabbedTick); } @Override