Search in sources :

Example 1 with PacketUpdateSearchStack

use of pneumaticCraft.common.network.PacketUpdateSearchStack in project PneumaticCraft by MineMaarten.

the class GuiSearchUpgradeOptions method initGui.

@Override
public void initGui(IGuiScreen gui) {
    gui.getButtonList().add(new GuiButton(10, 30, 40, 150, 20, "Search for item..."));
    gui.getButtonList().add(new GuiButton(11, 30, 128, 150, 20, "Move Stat Screen..."));
    if (searchGui != null && player.getCurrentArmor(3) != null) {
        ItemStack searchStack = searchGui.getSearchStack();
        ItemStack helmetStack = ItemPneumaticArmor.getSearchedStack(player.getCurrentArmor(3));
        if (searchStack == null && helmetStack != null || searchStack != null && helmetStack == null || searchStack != null && helmetStack != null && !searchStack.isItemEqual(helmetStack)) {
            NetworkHandler.sendToServer(new PacketUpdateSearchStack(searchStack));
            NBTTagCompound tag = NBTUtil.getCompoundTag(player.getCurrentArmor(3), "SearchStack");
            tag.setInteger("itemID", searchStack != null ? Item.getIdFromItem(searchStack.getItem()) : -1);
            tag.setInteger("itemDamage", searchStack != null ? searchStack.getItemDamage() : -1);
        }
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) PacketUpdateSearchStack(pneumaticCraft.common.network.PacketUpdateSearchStack)

Example 2 with PacketUpdateSearchStack

use of pneumaticCraft.common.network.PacketUpdateSearchStack in project PneumaticCraft by MineMaarten.

the class InventorySearch method setInventorySlotContents.

@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
    NBTTagCompound tag = NBTUtil.getCompoundTag(helmetStack, "SearchStack");
    tag.setInteger("itemID", itemstack != null ? Item.getIdFromItem(itemstack.getItem()) : -1);
    tag.setInteger("itemDamage", itemstack != null ? itemstack.getItemDamage() : -1);
    NetworkHandler.sendToServer(new PacketUpdateSearchStack(itemstack));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketUpdateSearchStack(pneumaticCraft.common.network.PacketUpdateSearchStack)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 PacketUpdateSearchStack (pneumaticCraft.common.network.PacketUpdateSearchStack)2 GuiButton (net.minecraft.client.gui.GuiButton)1 ItemStack (net.minecraft.item.ItemStack)1