use of com.almuradev.almura.shared.item.VirtualStack in project Almura by AlmuraDev.
the class ServerboundListItemsRequestPacket method writeTo.
@Override
public void writeTo(final ChannelBuf buf) {
checkNotNull(this.id);
checkNotNull(this.actions);
checkState(!this.actions.isEmpty());
buf.writeString(this.id);
buf.writeInteger(this.actions.size());
for (final InventoryAction action : this.actions) {
final VirtualStack stack = action.getStack();
final ResourceLocation location = stack.getItem().getRegistryName();
if (location == null) {
new IOException("Malformed resource location for Item '" + stack + "' when sending list item!").printStackTrace();
continue;
}
final NBTTagCompound compound = stack.getCompound();
byte[] compoundData = null;
if (compound != null) {
try {
compoundData = SerializationUtil.toBytes(compound);
} catch (IOException e) {
e.printStackTrace();
continue;
}
}
buf.writeString(action.getDirection().name().toUpperCase());
buf.writeString(location.getNamespace());
buf.writeString(location.getPath());
buf.writeInteger(stack.getQuantity());
buf.writeInteger(stack.getMetadata());
if (compoundData == null) {
buf.writeInteger(0);
} else {
buf.writeInteger(compoundData.length);
buf.writeBytes(compoundData);
}
}
}
Aggregations