More moves

This commit is contained in:
Sebastian Hartte
2020-07-01 01:39:50 +02:00
parent 1cda087c03
commit 996d387525
13 changed files with 9 additions and 19 deletions
@@ -237,32 +237,22 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
public static IAEFluidStack fromPacket(final PacketByteBuf buffer) { public static IAEFluidStack fromPacket(final PacketByteBuf buffer) {
final boolean isCraftable = buffer.readBoolean(); final boolean isCraftable = buffer.readBoolean();
CompoundTag volumeTag = buffer.readCompoundTag(); FluidKey fluid = FluidKey.fromTag(buffer.readCompoundTag());
final long stackSize = buffer.readVarLong(); CompoundTag compoundTag = buffer.readCompoundTag();
final long amount = buffer.readVarLong();
final long countRequestable = buffer.readVarLong(); final long countRequestable = buffer.readVarLong();
if (volumeTag == null) { final AEFluidStack fluidStack = new AEFluidStack(fluid, amount, compoundTag);
return null; fluidStack.setCountRequestable(countRequestable);
} fluidStack.setCraftable(isCraftable);
FluidVolume fluidStack = FluidVolume.fromTag(volumeTag); return fluidStack;
if (fluidStack.isEmpty()) {
return null;
}
final AEFluidStack fluid = AEFluidStack.fromFluidStack(fluidStack);
fluid.setStackSize(stackSize);
fluid.setCountRequestable(countRequestable);
fluid.setCraftable(isCraftable);
return fluid;
} }
@Override @Override
public void writeToPacket(final PacketByteBuf buffer) { public void writeToPacket(final PacketByteBuf buffer) {
buffer.writeBoolean(this.isCraftable()); buffer.writeBoolean(this.isCraftable());
// Cannot use writeFluidStack here because for FluidStacks with amount==0, it buffer.writeCompoundTag(fluid.toTag());
// will not write the fluid buffer.writeCompoundTag(tagCompound);
buffer.writeRegistryIdUnsafe(ForgeRegistries.FLUIDS, fluid);
buffer.writeCompoundTag(getFluidStack().getTag());
buffer.writeVarLong(this.getStackSize()); buffer.writeVarLong(this.getStackSize());
buffer.writeVarLong(this.getCountRequestable()); buffer.writeVarLong(this.getCountRequestable());
} }