public void appendItem( final IAEItemStack is ) throws IOException, BufferOverflowException { final ByteBuf tmp = Unpooled.buffer( OPERATION_BYTE_LIMIT ); is.writeToPacket( tmp ); this.compressFrame.flush(); if( this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT ) { throw new BufferOverflowException(); } else { this.writtenBytes += tmp.readableBytes(); this.compressFrame.write( tmp.array(), 0, tmp.readableBytes() ); this.empty = false; } }
public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is ) throws IOException { final ByteBuf data = Unpooled.buffer(); data.writeInt( this.getPacketID() ); data.writeInt( this.x = pos.getX() ); data.writeInt( this.y = pos.getY() ); data.writeInt( this.z = pos.getZ() ); data.writeByte( this.rate = rate ); is.writeToPacket( data ); this.is = is; this.configureWrite( data ); }
private void writeItem( final IAEItemStack slotItem, final ByteBuf data ) throws IOException { if( slotItem == null ) { data.writeBoolean( false ); } else { data.writeBoolean( true ); slotItem.writeToPacket( data ); } }
@Override public void writeToStream( final ByteBuf data ) throws IOException { super.writeToStream( data ); data.writeBoolean( this.isLocked ); data.writeBoolean( this.configuredItem != null ); if( this.configuredItem != null ) { this.configuredItem.writeToPacket( data ); } }
@Override protected void writeToStream( final ByteBuf data ) throws IOException { super.writeToStream( data ); data.writeByte( this.paintedColor.ordinal() ); if( this.dspPlay == null ) { data.writeBoolean( false ); } else { data.writeBoolean( true ); this.dspPlay.writeToPacket( data ); } }
public PacketInventoryAction( final InventoryAction action, final int slot, final IAEItemStack slotItem ) throws IOException { if( Platform.isClient() ) { throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." ); } this.action = action; this.slot = slot; this.id = 0; this.slotItem = slotItem; final ByteBuf data = Unpooled.buffer(); data.writeInt( this.getPacketID() ); data.writeInt( action.ordinal() ); data.writeInt( slot ); data.writeLong( this.id ); if( slotItem == null ) { data.writeBoolean( false ); } else { data.writeBoolean( true ); slotItem.writeToPacket( data ); } this.configureWrite( data ); }
@Override public void toBytes(ByteBuf buf) { for (IAEItemStack stack : this.list) { try { stack.writeToPacket(buf); } catch (IOException e) { e.printStackTrace(); } } }
public void appendItem(final IAEItemStack is) throws IOException, BufferOverflowException { final ByteBuf tmp = Unpooled.buffer(OPERATION_BYTE_LIMIT); is.writeToPacket(tmp); compressFrame.flush(); if (writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) { throw new BufferOverflowException(); } else { writtenBytes += tmp.readableBytes(); compressFrame.write(tmp.array(), 0, tmp.readableBytes()); empty = false; } }
public PacketInventoryAction(final InventoryAction action, final int slot, final IAEItemStack slotItem) throws IOException { if (Platform.isClient()) { throw new IllegalStateException("invalid packet, client cannot post inv actions with stacks."); } this.action = action; this.slot = slot; id = 0; this.slotItem = slotItem; final ByteBuf data = Unpooled.buffer(); data.writeInt(getPacketID()); data.writeInt(action.ordinal()); data.writeInt(slot); data.writeLong(id); if (slotItem == null) { data.writeBoolean(false); } else { data.writeBoolean(true); slotItem.writeToPacket(data); } configureWrite(data); }