Fix conveyor grabber delay

This commit is contained in:
abel1502 2024-09-23 18:21:57 +03:00
parent 33c8ad70a3
commit 8aad7fb44b
No known key found for this signature in database
GPG Key ID: 076926596A536338

View File

@ -32,6 +32,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
public boolean isWhitelist = false; public boolean isWhitelist = false;
public ModulePatternMatcher matcher; public ModulePatternMatcher matcher;
public long lastGrabbedTick = 0;
public TileEntityCraneGrabber() { public TileEntityCraneGrabber() {
super(11); 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; int amount = 1;
if(slots[9] != null && slots[9].getItem() == ModItems.upgrade_stack) { 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); boolean match = this.matchesFilter(stack);
if(this.isWhitelist && !match || !this.isWhitelist && match) continue; if(this.isWhitelist && !match || !this.isWhitelist && match) continue;
lastGrabbedTick = worldObj.getTotalWorldTime();
ItemStack copy = stack.copy(); ItemStack copy = stack.copy();
int toAdd = Math.min(stack.stackSize, amount); int toAdd = Math.min(stack.stackSize, amount);
copy.stackSize = toAdd; copy.stackSize = toAdd;
@ -132,8 +135,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setBoolean("isWhitelist", isWhitelist); this.writeToNBT(data);
this.matcher.writeToNBT(data);
this.networkPack(data, 15); this.networkPack(data, 15);
} }
} }
@ -141,9 +143,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
public void networkUnpack(NBTTagCompound nbt) { public void networkUnpack(NBTTagCompound nbt) {
super.networkUnpack(nbt); super.networkUnpack(nbt);
this.isWhitelist = nbt.getBoolean("isWhitelist"); this.readFromNBT(nbt);
this.matcher.modes = new String[this.matcher.modes.length];
this.matcher.readFromNBT(nbt);
} }
public boolean matchesFilter(ItemStack stack) { public boolean matchesFilter(ItemStack stack) {
@ -175,6 +175,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.isWhitelist = nbt.getBoolean("isWhitelist"); this.isWhitelist = nbt.getBoolean("isWhitelist");
this.matcher.readFromNBT(nbt); this.matcher.readFromNBT(nbt);
this.lastGrabbedTick = nbt.getLong("lastGrabbedTick");
} }
@Override @Override
@ -182,6 +183,7 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setBoolean("isWhitelist", this.isWhitelist); nbt.setBoolean("isWhitelist", this.isWhitelist);
this.matcher.writeToNBT(nbt); this.matcher.writeToNBT(nbt);
nbt.setLong("lastGrabbedTick", lastGrabbedTick);
} }
@Override @Override