fix massive result of idiocy in pipe packet sending
This commit is contained in:
parent
c085a1e9a2
commit
5cd4700836
5 changed files with 26 additions and 18 deletions
|
@ -310,9 +310,8 @@ public class PipeTransportItems extends PipeTransport implements IDebuggable {
|
|||
|
||||
if (item.output == ForgeDirection.UNKNOWN) {
|
||||
// TODO: Figure out why this is actually happening.
|
||||
if (items.scheduleRemoval(item)) {
|
||||
dropItem(item);
|
||||
}
|
||||
items.scheduleRemoval(item);
|
||||
BCLog.logger.warn("Glitched item [Output direction UNKNOWN] removed from world @ " + container.x() + ", " + container.y() + ", " + container.z() + "!");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -440,7 +439,7 @@ public class PipeTransportItems extends PipeTransport implements IDebuggable {
|
|||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (TravelingItem item : items) {
|
||||
for (TravelingItem item : items.toArray(new TravelingItem[items.size()])) {
|
||||
NBTTagCompound dataTag = new NBTTagCompound();
|
||||
nbttaglist.appendTag(dataTag);
|
||||
item.writeToNBT(dataTag);
|
||||
|
|
|
@ -182,13 +182,14 @@ public class PipeFluidsDiamond extends Pipe<PipeTransportFluids> implements IDia
|
|||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
NetworkUtils.writeNBT(data, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
NBTTagCompound nbt = NetworkUtils.readNBT(data);
|
||||
readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
filters.markDirty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,14 +86,14 @@ public class PipeFluidsEmerald extends PipeFluidsWood implements ISerializable {
|
|||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
NetworkUtils.writeNBT(data, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
NBTTagCompound nbt = NetworkUtils.readNBT(data);
|
||||
readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -207,13 +207,17 @@ public class PipeItemsDiamond extends Pipe<PipeTransportItems> implements IDiamo
|
|||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
nbt.setLong("usedFilters", usedFilters);
|
||||
NetworkUtils.writeNBT(data, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
NBTTagCompound nbt = NetworkUtils.readNBT(data);
|
||||
readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
if (nbt.hasKey("usedFilters")) {
|
||||
usedFilters = nbt.getLong("usedFilters");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,20 +197,20 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISerializable, IG
|
|||
}
|
||||
|
||||
private void incrementFilter() {
|
||||
currentFilter++;
|
||||
currentFilter = (currentFilter + 1) % filters.getSizeInventory();
|
||||
int count = 0;
|
||||
while (filters.getStackInSlot(currentFilter % filters.getSizeInventory()) == null && count < filters.getSizeInventory()) {
|
||||
currentFilter++;
|
||||
while (filters.getStackInSlot(currentFilter) == null && count < filters.getSizeInventory()) {
|
||||
currentFilter = (currentFilter + 1) % filters.getSizeInventory();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getCurrentFilter() {
|
||||
ItemStack filter = filters.getStackInSlot(currentFilter % filters.getSizeInventory());
|
||||
ItemStack filter = filters.getStackInSlot(currentFilter);
|
||||
if (filter == null) {
|
||||
incrementFilter();
|
||||
}
|
||||
return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
|
||||
return filters.getStackInSlot(currentFilter);
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
|
@ -224,14 +224,18 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISerializable, IG
|
|||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
settings.writeToNBT(nbt);
|
||||
NetworkUtils.writeNBT(data, nbt);
|
||||
data.writeByte(currentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
NBTTagCompound nbt = NetworkUtils.readNBT(data);
|
||||
readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
settings.readFromNBT(nbt);
|
||||
currentFilter = data.readUnsignedByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +245,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISerializable, IG
|
|||
filters.readFromNBT(nbt);
|
||||
settings.readFromNBT(nbt);
|
||||
|
||||
currentFilter = nbt.getInteger("currentFilter");
|
||||
currentFilter = nbt.getInteger("currentFilter") % filters.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue