Send correct size

This commit is contained in:
Raoul Van den Berge
2016-11-27 12:49:40 +01:00
parent f3d0e4e681
commit 086f1fb4ba
2 changed files with 13 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ public class FluidStackList implements IFluidStackList {
@Override
public boolean trackedRemove(@Nonnull FluidStack stack, int size, boolean removeIfReachedZero) {
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
if (otherStack.amount > 0 && stack.isFluidEqual(otherStack)) {
if (stack.isFluidEqual(otherStack)) {
FluidStack removed = new FluidStack(otherStack.getFluid(), Math.min(size, otherStack.amount));
this.removeTracker.add(removed);
otherStack.amount -= size;

View File

@@ -30,14 +30,24 @@ public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageG
public void fromBytes(ByteBuf buf) {
int items = buf.readInt();
for (int i = 0; i < items + 1; ++i) {
for (int i = 0; i < items; ++i) {
this.stacks.add(new ClientStackItem(buf));
}
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(network.getItemStorageCache().getList().getStacks().size());
int size = network.getItemStorageCache().getList().getStacks().size();
for (ICraftingPattern pattern : network.getPatterns()) {
for (ItemStack output : pattern.getOutputs()) {
if (output != null) {
size++;
}
}
}
buf.writeInt(size);
for (ItemStack stack : network.getItemStorageCache().getList().getStacks()) {
RSUtils.writeItemStack(buf, network, stack, false);