Search in sources :

Example 41 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project LogisticsPipes by RS485.

the class GuiDiskPopup method renderGuiBackground.

@Override
protected void renderGuiBackground(int par1, int par2) {
    GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
    mc.fontRenderer.drawStringWithShadow("Disk", xCenter - (mc.fontRenderer.getStringWidth("Disk") / 2), guiTop + 10, 0xFFFFFF);
    //NameInput
    if (editname) {
        Gui.drawRect(guiLeft + 10, guiTop + 28, right - 10, guiTop + 45, Color.getValue(Color.BLACK));
        Gui.drawRect(guiLeft + 11, guiTop + 29, right - 11, guiTop + 44, Color.getValue(Color.WHITE));
    } else {
        Gui.drawRect(guiLeft + 11, guiTop + 29, right - 11, guiTop + 44, Color.getValue(Color.BLACK));
    }
    Gui.drawRect(guiLeft + 12, guiTop + 30, right - 12, guiTop + 43, Color.getValue(Color.DARKER_GREY));
    mc.fontRenderer.drawString(name1 + name2, guiLeft + 15, guiTop + 33, 0xFFFFFF);
    Gui.drawRect(guiLeft + 6, guiTop + 46, right - 6, bottom - 30, Color.getValue(Color.GREY));
    NBTTagCompound nbt = diskProvider.getDisk().getTagCompound();
    if (nbt == null) {
        diskProvider.getDisk().setTagCompound(new NBTTagCompound());
        nbt = diskProvider.getDisk().getTagCompound();
    }
    if (!nbt.hasKey("macroList")) {
        NBTTagList list = new NBTTagList();
        nbt.setTag("macroList", list);
    }
    NBTTagList list = nbt.getTagList("macroList", 10);
    if (scroll + 12 > list.tagCount()) {
        scroll = list.tagCount() - 12;
    }
    if (scroll < 0) {
        scroll = 0;
    }
    boolean flag = false;
    if (guiLeft + 8 < mouseX && mouseX < right - 8 && guiTop + 48 < mouseY && mouseY < guiTop + 59 + (11 * 10)) {
        selected = scroll + (mouseY - guiTop - 49) / 10;
    }
    for (int i = scroll; i < list.tagCount() && (i - scroll) < 12; i++) {
        if (i == selected) {
            Gui.drawRect(guiLeft + 8, guiTop + 48 + ((i - scroll) * 10), right - 8, guiTop + 59 + ((i - scroll) * 10), Color.getValue(Color.DARKER_GREY));
            flag = true;
        }
        NBTTagCompound entry = list.getCompoundTagAt(i);
        String name = entry.getString("name");
        mc.fontRenderer.drawString(name, guiLeft + 10, guiTop + 50 + ((i - scroll) * 10), 0xFFFFFF);
    }
    if (!flag) {
        selected = -1;
    }
    if (editname) {
        int linex = guiLeft + 15 + mc.fontRenderer.getStringWidth(name1);
        if (System.currentTimeMillis() - oldSystemTime > 500) {
            displaycursor = !displaycursor;
            oldSystemTime = System.currentTimeMillis();
        }
        if (displaycursor) {
            Gui.drawRect(linex, guiTop + 31, linex + 1, guiTop + 42, Color.getValue(Color.WHITE));
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 42 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project LogisticsPipes by RS485.

the class ModuleCrafter method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
    //	super.writeToNBT(nbttagcompound);
    _dummyInventory.writeToNBT(nbttagcompound, "");
    _liquidInventory.writeToNBT(nbttagcompound, "FluidInv");
    _cleanupInventory.writeToNBT(nbttagcompound, "CleanupInv");
    nbttagcompound.setInteger("satelliteid", satelliteId);
    nbttagcompound.setInteger("priority", priority);
    for (int i = 0; i < 9; i++) {
        nbttagcompound.setInteger("advancedSatelliteId" + i, advancedSatelliteIdArray[i]);
    }
    NBTTagList lst = new NBTTagList();
    for (int i = 0; i < 9; i++) {
        NBTTagCompound comp = new NBTTagCompound();
        comp.setBoolean("ignore_dmg", fuzzyCraftingFlagArray[i].ignore_dmg);
        comp.setBoolean("ignore_nbt", fuzzyCraftingFlagArray[i].ignore_nbt);
        comp.setBoolean("use_od", fuzzyCraftingFlagArray[i].use_od);
        comp.setBoolean("use_category", fuzzyCraftingFlagArray[i].use_category);
        lst.appendTag(comp);
    }
    nbttagcompound.setTag("fuzzyFlags", lst);
    {
        NBTTagCompound comp = new NBTTagCompound();
        comp.setBoolean("ignore_dmg", outputFuzzyFlags.ignore_dmg);
        comp.setBoolean("ignore_nbt", outputFuzzyFlags.ignore_nbt);
        comp.setBoolean("use_od", outputFuzzyFlags.use_od);
        comp.setBoolean("use_category", outputFuzzyFlags.use_category);
        nbttagcompound.setTag("outputFuzzyFlags", comp);
    }
    for (int i = 0; i < 6; i++) {
        nbttagcompound.setBoolean("craftingSigns" + i, craftingSigns[i]);
    }
    for (int i = 0; i < ItemUpgrade.MAX_LIQUID_CRAFTER; i++) {
        nbttagcompound.setInteger("liquidSatelliteIdArray" + i, liquidSatelliteIdArray[i]);
    }
    nbttagcompound.setIntArray("FluidAmount", amount);
    nbttagcompound.setInteger("liquidSatelliteId", liquidSatelliteId);
    nbttagcompound.setBoolean("cleanupModeIsExclude", cleanupModeIsExclude);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 43 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project LogisticsPipes by RS485.

the class ItemModuleInformationManager method removeInformation.

public static void removeInformation(ItemStack itemStack) {
    if (itemStack == null) {
        return;
    }
    if (itemStack.hasTagCompound()) {
        NBTTagCompound nbt = itemStack.getTagCompound();
        @SuppressWarnings("unchecked") Collection<String> collection = nbt.tagMap.keySet();
        nbt = new NBTTagCompound();
        for (String key : collection) {
            if (!ItemModuleInformationManager.Filter.contains(key)) {
                nbt.setTag(key, nbt.getTag(key));
            }
        }
        itemStack.setTagCompound(nbt);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 44 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project LogisticsPipes by RS485.

the class ItemModule method addInformation.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean flag) {
    if (itemStack.hasTagCompound()) {
        NBTTagCompound nbt = itemStack.getTagCompound();
        if (nbt.hasKey("informationList")) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
                NBTTagList nbttaglist = nbt.getTagList("informationList", 8);
                for (int i = 0; i < nbttaglist.tagCount(); i++) {
                    Object nbttag = nbttaglist.tagList.get(i);
                    String data = ((NBTTagString) nbttag).func_150285_a_();
                    if (data.equals("<inventory>") && i + 1 < nbttaglist.tagCount()) {
                        nbttag = nbttaglist.tagList.get(i + 1);
                        data = ((NBTTagString) nbttag).func_150285_a_();
                        if (data.startsWith("<that>")) {
                            String prefix = data.substring(6);
                            NBTTagCompound module = nbt.getCompoundTag("moduleInformation");
                            int size = module.getTagList(prefix + "items", module.getId()).tagCount();
                            if (module.hasKey(prefix + "itemsCount")) {
                                size = module.getInteger(prefix + "itemsCount");
                            }
                            ItemIdentifierInventory inv = new ItemIdentifierInventory(size, "InformationTempInventory", Integer.MAX_VALUE);
                            inv.readFromNBT(module, prefix);
                            for (int pos = 0; pos < inv.getSizeInventory(); pos++) {
                                ItemIdentifierStack stack = inv.getIDStackInSlot(pos);
                                if (stack != null) {
                                    if (stack.getStackSize() > 1) {
                                        list.add("  " + stack.getStackSize() + "x " + stack.getFriendlyName());
                                    } else {
                                        list.add("  " + stack.getFriendlyName());
                                    }
                                }
                            }
                        }
                        i++;
                    } else {
                        list.add(data);
                    }
                }
            } else {
                list.add(StringUtils.translate(StringUtils.KEY_HOLDSHIFT));
            }
        } else {
            StringUtils.addShiftAddition(itemStack, list);
        }
    } else {
        StringUtils.addShiftAddition(itemStack, list);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 45 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project LogisticsPipes by RS485.

the class ItemPipeSignCreator method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (MainProxy.isClient(world)) {
        return stack;
    }
    if (player.isSneaking()) {
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
        }
        if (!stack.getTagCompound().hasKey("PipeClicked")) {
            int mode = stack.getTagCompound().getInteger("CreatorMode");
            mode++;
            if (mode >= ItemPipeSignCreator.signTypes.size()) {
                mode = 0;
            }
            stack.getTagCompound().setInteger("CreatorMode", mode);
        }
    }
    if (stack.hasTagCompound()) {
        stack.getTagCompound().removeTag("PipeClicked");
    }
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3985 NBTTagList (net.minecraft.nbt.NBTTagList)1052 ItemStack (net.minecraft.item.ItemStack)883 BlockPos (net.minecraft.util.math.BlockPos)229 TileEntity (net.minecraft.tileentity.TileEntity)173 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)148 ArrayList (java.util.ArrayList)99 Block (net.minecraft.block.Block)98 ResourceLocation (net.minecraft.util.ResourceLocation)96 IBlockState (net.minecraft.block.state.IBlockState)92 EntityPlayer (net.minecraft.entity.player.EntityPlayer)81 NBTTagString (net.minecraft.nbt.NBTTagString)79 Nonnull (javax.annotation.Nonnull)74 Map (java.util.Map)71 UUID (java.util.UUID)69 NBTBase (net.minecraft.nbt.NBTBase)66 HashMap (java.util.HashMap)64 EnumFacing (net.minecraft.util.EnumFacing)61 NotNull (org.jetbrains.annotations.NotNull)60 Item (net.minecraft.item.Item)55