Search in sources :

Example 26 with PacketCustom

use of codechicken.lib.packet.PacketCustom in project Galacticraft by micdoodle8.

the class NEISPH method processCreativeInv.

public static void processCreativeInv(EntityPlayerMP sender, boolean open) {
    if (open) {
        ServerUtils.openSMPContainer(sender, new ContainerCreativeInv(sender, new ExtendedCreativeInv(NEIServerConfig.forPlayer(sender.getName()), Side.SERVER)), new IGuiPacketSender() {

            @Override
            public void sendPacket(EntityPlayerMP player, int windowId) {
                PacketCustom packet = new PacketCustom(channel, 23);
                packet.writeBoolean(true);
                packet.writeByte(windowId);
                packet.sendToPlayer(player);
            }
        });
    } else {
        sender.closeContainer();
        PacketCustom packet = new PacketCustom(channel, 23);
        packet.writeBoolean(false);
        packet.sendToPlayer(sender);
    }
}
Also used : IGuiPacketSender(codechicken.core.IGuiPacketSender) PacketCustom(codechicken.lib.packet.PacketCustom) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 27 with PacketCustom

use of codechicken.lib.packet.PacketCustom in project Galacticraft by micdoodle8.

the class ContainerSynchronised method sendContainerAndContentsToPlayer.

@Override
public void sendContainerAndContentsToPlayer(Container container, List<ItemStack> list, List<EntityPlayerMP> playerCrafters) {
    super.sendContainerAndContentsToPlayer(container, list, playerCrafters);
    for (int i = 0; i < syncVars.size(); i++) {
        IContainerSyncVar var = syncVars.get(i);
        PacketCustom packet = createSyncPacket();
        packet.writeByte(i);
        var.writeChange(packet);
        var.reset();
        for (EntityPlayerMP player : playerCrafters) {
            packet.sendToPlayer(player);
        }
    }
}
Also used : PacketCustom(codechicken.lib.packet.PacketCustom) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

PacketCustom (codechicken.lib.packet.PacketCustom)27 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 ItemStack (net.minecraft.item.ItemStack)3 IGuiPacketSender (codechicken.core.IGuiPacketSender)2 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 InventoryBasic (net.minecraft.inventory.InventoryBasic)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1