Java Code Examples for codechicken.lib.packet.PacketCustom#writeItemStack()

The following examples show how to use codechicken.lib.packet.PacketCustom#writeItemStack() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Tells the server to cheat a specific item to the player.
 *
 * @param stack    The stack to cheat.
 * @param infinite If the stack should be infinite or not.
 * @param doSpawn  If the server should actually give the item.
 */
public static void sendGiveItem(ItemStack stack, boolean infinite, boolean doSpawn) {
    PacketCustom packet = new PacketCustom(channel, 1);
    packet.writeItemStack(stack);
    packet.writeBoolean(infinite);
    packet.writeBoolean(doSpawn);
    packet.sendToServer();
}
 
Example 2
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Sets a specific slot on the players inventory to the given item.
 *
 * @param slot      The slot to change.
 * @param stack     The stack to set the slot to.
 * @param container if the inventory is a container.
 */
public static void sendSetSlot(int slot, ItemStack stack, boolean container) {
    PacketCustom packet = new PacketCustom(channel, 5);
    packet.writeBoolean(container);
    packet.writeShort(slot);
    packet.writeItemStack(stack);
    packet.sendToServer();
}
 
Example 3
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void sendOpenPotionWindow() {
    ItemStack[] potionStore = new ItemStack[9];
    ArrayUtils.fillArray(potionStore, ItemStack.EMPTY);
    InventoryUtils.readItemStacksFromTag(potionStore, NEIClientConfig.global.nbt.getCompoundTag("potionStore").getTagList("items", 10));
    PacketCustom packet = new PacketCustom(channel, 24);
    for (ItemStack stack : potionStore) {
        packet.writeItemStack(stack);
    }
    packet.sendToServer();
}
 
Example 4
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void sendGiveItem(ItemStack spawnstack, boolean infinite, boolean doSpawn) {
    PacketCustom packet = new PacketCustom(channel, 1);
    packet.writeItemStack(spawnstack);
    packet.writeBoolean(infinite);
    packet.writeBoolean(doSpawn);
    packet.sendToServer();
}
 
Example 5
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void sendSetSlot(int slot, ItemStack stack, boolean container) {
    PacketCustom packet = new PacketCustom(channel, 5);
    packet.writeBoolean(container);
    packet.writeShort(slot);
    packet.writeItemStack(stack);
    packet.sendToServer();
}
 
Example 6
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void sendOpenPotionWindow() {
    ItemStack[] potionStore = new ItemStack[9];
    InventoryUtils.readItemStacksFromTag(potionStore, NEIClientConfig.global.nbt.getCompoundTag("potionStore").getTagList("items", 10));
    PacketCustom packet = new PacketCustom(channel, 24);
    for (ItemStack stack : potionStore)
        packet.writeItemStack(stack);
    packet.sendToServer();
}
 
Example 7
Source File: TileItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
private void sendTransferPacket(int i, int j, ItemStack add)
{
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 2);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeByte(i << 4 | j);
    packet.writeItemStack(add);
    packet.sendToChunk(worldObj, xCoord>>4, zCoord>>4);
}
 
Example 8
Source File: TileCraftingGrid.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public Packet getDescriptionPacket() {
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 3);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeByte(rotation);
    for (ItemStack item : items)
        packet.writeItemStack(item);

    return packet.toPacket();
}
 
Example 9
Source File: ContainerItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public void sendLargeStack(ItemStack stack, int slot, List<EntityPlayerMP> players) {
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 5);
    packet.writeByte(slot);
    packet.writeItemStack(stack, true);

    for (EntityPlayerMP player : players)
        packet.sendToPlayer(player);
}
 
Example 10
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendDummySlotSet(int slotNumber, ItemStack stack) {
    PacketCustom packet = new PacketCustom(channel, 25);
    packet.writeShort(slotNumber);
    packet.writeItemStack(stack);
    packet.sendToServer();
}
 
Example 11
Source File: NEICPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendDummySlotSet(int slotNumber, ItemStack stack) {
    PacketCustom packet = new PacketCustom(channel, 25);
    packet.writeShort(slotNumber);
    packet.writeItemStack(stack);
    packet.sendToServer();
}