Search in sources :

Example 11 with PacketCustom

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

the class NEIServerUtils method setGamemode.

public static void setGamemode(EntityPlayerMP player, int mode) {
    if (mode < 0 || mode >= NEIActions.gameModes.length || NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) && !NEIServerConfig.canPlayerPerformAction(player.getName(), NEIActions.gameModes[mode])) {
        return;
    }
    // creative+
    NEIServerConfig.forPlayer(player.getName()).enableAction("creative+", mode == 2);
    if (// open the container immediately for the client
    mode == 2 && !(player.openContainer instanceof ContainerCreativeInv)) {
        NEISPH.processCreativeInv(player, true);
    }
    // change it on the server
    player.theItemInWorldManager.setGameType(getGameType(mode));
    // tell the client to change it
    new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
    player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) PacketCustom(codechicken.lib.packet.PacketCustom)

Example 12 with PacketCustom

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

the class NEICPH method sendOpenPotionWindow.

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();
}
Also used : PacketCustom(codechicken.lib.packet.PacketCustom) ItemStack(net.minecraft.item.ItemStack)

Example 13 with PacketCustom

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

the class NEICPH method sendToggleMagnetMode.

public static void sendToggleMagnetMode() {
    PacketCustom packet = new PacketCustom(channel, 6);
    packet.sendToServer();
}
Also used : PacketCustom(codechicken.lib.packet.PacketCustom)

Example 14 with PacketCustom

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

the class NEICPH method sendCreativeInv.

public static void sendCreativeInv(boolean open) {
    PacketCustom packet = new PacketCustom(channel, 23);
    packet.writeBoolean(open);
    packet.sendToServer();
}
Also used : PacketCustom(codechicken.lib.packet.PacketCustom)

Example 15 with PacketCustom

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

the class NEICPH method sendDeleteAllItems.

public static void sendDeleteAllItems() {
    PacketCustom packet = new PacketCustom(channel, 4);
    packet.sendToServer();
}
Also used : PacketCustom(codechicken.lib.packet.PacketCustom)

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