cn.nukkit.network.protocol.InventoryContentPacket Maven / Gradle / Ivy
package cn.nukkit.network.protocol;
import cn.nukkit.item.Item;
import lombok.ToString;
/**
* @author MagicDroidX (Nukkit Project)
*/
@ToString
public class InventoryContentPacket extends DataPacket {
public static final byte NETWORK_ID = ProtocolInfo.INVENTORY_CONTENT_PACKET;
@Override
public byte pid() {
return NETWORK_ID;
}
public static final int SPECIAL_INVENTORY = 0;
public static final int SPECIAL_OFFHAND = 0x77;
public static final int SPECIAL_ARMOR = 0x78;
public static final int SPECIAL_CREATIVE = 0x79;
public static final int SPECIAL_HOTBAR = 0x7a;
public static final int SPECIAL_FIXED_INVENTORY = 0x7b;
public int inventoryId;
public Item[] slots = Item.EMPTY_ARRAY;
@Override
public DataPacket clean() {
this.slots = Item.EMPTY_ARRAY;
return super.clean();
}
@Override
public void decode() {
}
@Override
public void encode() {
this.reset();
this.putUnsignedVarInt(this.inventoryId);
this.putUnsignedVarInt(this.slots.length);
for (Item slot : this.slots) {
this.putSlot(slot);
}
}
@Override
public InventoryContentPacket clone() {
InventoryContentPacket pk = (InventoryContentPacket) super.clone();
pk.slots = this.slots.clone();
return pk;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy