Java Code Examples for net.minecraft.item.ItemStack#loadItemStackFromNBT()
The following examples show how to use
net.minecraft.item.ItemStack#loadItemStackFromNBT() .
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: TileEntityOmnidirectionalHopper.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); inputDir = ForgeDirection.getOrientation(tag.getInteger("inputDir")); redstoneMode = tag.getInteger("redstoneMode"); leaveMaterial = tag.getBoolean("leaveMaterial"); NBTTagList tagList = tag.getTagList("Inventory", 10); inventory = new ItemStack[inventory.length]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 2
Source File: TileEntityAutoChisel.java From Chisel-2 with GNU General Public License v2.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList tags = nbt.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for (int i = 0; i < tags.tagCount(); i++) { NBTTagCompound data = tags.getCompoundTagAt(i); int j = data.getByte("Slot") & 255; if (j >= 0 && j < inventory.length) { inventory[j] = ItemStack.loadItemStackFromNBT(data); } } if (nbt.hasKey("CustomName", 8)) { this.name = nbt.getString("CustomName"); } }
Example 3
Source File: TileEntityAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbtTagCompound){ super.readFromNBT(nbtTagCompound); burnTime = nbtTagCompound.getInteger("burnTime"); maxBurnTime = nbtTagCompound.getInteger("maxBurn"); redstoneMode = nbtTagCompound.getInteger("redstoneMode"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 4
Source File: EventHandlerWorld.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent(priority = EventPriority.NORMAL) public void on(ItemTooltipEvent e) { if (e.toolTip.size() > 0 && e.itemStack.hasTagCompound()) { if (e.itemStack.stackTagCompound.getBoolean("isStickyJar")) { e.toolTip.add(1, "\u00a7a" + StatCollector.translateToLocal("gadomancy.lore.stickyjar")); } } if(e.toolTip.size() > 0 && NBTHelper.hasPersistentData(e.itemStack)) { NBTTagCompound compound = NBTHelper.getPersistentData(e.itemStack); if(compound.hasKey("disguise")) { NBTBase base = compound.getTag("disguise"); String lore; if(base instanceof NBTTagCompound) { ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) base); lore = String.format(StatCollector.translateToLocal("gadomancy.lore.disguise.item"), EnumChatFormatting.getTextWithoutFormattingCodes(stack.getDisplayName())); } else { lore = StatCollector.translateToLocal("gadomancy.lore.disguise.none"); } e.toolTip.add("\u00a7a" + lore); } } }
Example 5
Source File: TileEntityBabyChest.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound pNBTTagCompound) { super.readFromNBT(pNBTTagCompound); NBTTagList tNBTtaglist = pNBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); _mInventory = new ItemStack[getSizeInventory()]; for (int i = 0; i < tNBTtaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = tNBTtaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xff; if (j >= 0 && j < _mInventory.length) { _mInventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } if ( pNBTTagCompound.hasKey( "facing" )) setOrientation( pNBTTagCompound.getByte( "facing" ) ); }
Example 6
Source File: TileEntityElectrostaticCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbtTagCompound){ super.readFromNBT(nbtTagCompound); redstoneMode = nbtTagCompound.getInteger("redstoneMode"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 7
Source File: TileEntityUVLightBox.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); redstoneMode = nbt.getInteger("redstoneMode"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbt.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // if(worldObj.isRemote) System.out.println("reading from NBT, got a packet?"); }
Example 8
Source File: TileEntityElectricCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbtTagCompound){ super.readFromNBT(nbtTagCompound); redstoneMode = nbtTagCompound.getInteger("redstoneMode"); outputTimer = nbtTagCompound.getBoolean("outputTimer") ? 20 : 0; turbineSpeed = nbtTagCompound.getFloat("turbineSpeed"); lastEnergyProduction = nbtTagCompound.getInteger("energyProduction"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 9
Source File: TileEntityPressureChamberInterface.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } outputProgress = tag.getInteger("outputProgress"); inputProgress = tag.getInteger("inputProgress"); interfaceMode = EnumInterfaceMode.values()[tag.getInteger("interfaceMode")]; filterMode = EnumFilterMode.values()[tag.getInteger("filterMode")]; creativeTabID = tag.getInteger("creativeTabID"); itemNameFilter = tag.getString("itemNameFilter"); redstoneMode = tag.getInteger("redstoneMode"); }
Example 10
Source File: TileEntityPneumaticDoorBase.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); progress = tag.getFloat("extension"); opening = tag.getBoolean("opening"); redstoneMode = tag.getInteger("redstoneMode"); orientation = ForgeDirection.getOrientation(tag.getInteger("orientation")); rightGoing = tag.getBoolean("rightGoing"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 11
Source File: ItemBlueprint.java From Cyberware with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { if (stack.hasTagCompound()) { NBTTagCompound comp = stack.getTagCompound(); if (comp.hasKey("blueprintItem")) { GameSettings settings = Minecraft.getMinecraft().gameSettings; if (settings.isKeyDown(settings.keyBindSneak)) { ItemStack blueprintItem = ItemStack.loadItemStackFromNBT(comp.getCompoundTag("blueprintItem")); if (blueprintItem != null && CyberwareAPI.canDeconstruct(blueprintItem)) { ItemStack[] items = CyberwareAPI.getComponents(blueprintItem).clone(); tooltip.add(I18n.format("cyberware.tooltip.blueprint", blueprintItem.getDisplayName())); for (ItemStack item : items) { if (item != null) { tooltip.add(item.stackSize + " x " + item.getDisplayName()); } } return; } } else { tooltip.add(ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.shiftPrompt", Minecraft.getMinecraft().gameSettings.keyBindSneak.getDisplayName())); return; } } } tooltip.add(ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.craftBlueprint")); }
Example 12
Source File: TileEntityEtherealMacerator.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList nbttaglist = tagCompound.getTagList("Items", 10); this.slots = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.slots.length) { this.slots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } this.cookTime = tagCompound.getShort("CookTime"); }
Example 13
Source File: ItemMinigun.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int getAmmoColor(){ ItemStack ammo = null; if(NBTUtil.hasTag(stack, "ammoColorStack")) { NBTTagCompound tag = NBTUtil.getCompoundTag(stack, "ammoColorStack"); ammo = ItemStack.loadItemStackFromNBT(tag); } return getAmmoColor(ammo); }
Example 14
Source File: ItemSubCollar.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
@Override public ItemStack getCosmeticItem(ItemStack stack) { if(stack == null || stack.getTagCompound() == null) return null; if(!stack.getTagCompound().hasKey("cosmeticItem")) return null; NBTTagCompound cosmetic = stack.getTagCompound().getCompoundTag("cosmeticItem"); return ItemStack.loadItemStackFromNBT(cosmetic); }
Example 15
Source File: InventoryUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * NBT item loading function with support for stack sizes > 32K */ public static void readItemStacksFromTag(ItemStack[] items, NBTTagList tagList) { for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = tagList.getCompoundTagAt(i); int b = tag.getShort("Slot"); items[b] = ItemStack.loadItemStackFromNBT(tag); if (tag.hasKey("Quantity")) items[b].stackSize = ((NBTBase.NBTPrimitive) tag.getTag("Quantity")).getInt(); } }
Example 16
Source File: RenderEventHandler.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void renderEntityPre(RenderLivingEvent.Pre event) { if(event.entity instanceof EntityPlayer) { EntityPlayer p = (EntityPlayer) event.entity; if(((DataAchromatic)SyncDataHolder.getDataClient("AchromaticData")).isAchromatic((EntityPlayer) event.entity)) { current = p; GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); } armor = p.inventory.armorInventory; p.inventory.armorInventory = new ItemStack[armor.length]; System.arraycopy(armor, 0, p.inventory.armorInventory, 0, armor.length); boolean changed = false; for(int i = 0; i < armor.length; i++) { if(armor[i] != null && NBTHelper.hasPersistentData(armor[i])) { NBTTagCompound compound = NBTHelper.getPersistentData(armor[i]); if(compound.hasKey("disguise")) { NBTBase base = compound.getTag("disguise"); if(base instanceof NBTTagCompound) { p.inventory.armorInventory[i] = ItemStack.loadItemStackFromNBT((NBTTagCompound) base); } else { p.inventory.armorInventory[i] = null; } changed = true; } } } if(!changed) { p.inventory.armorInventory = armor; armor = null; } } }
Example 17
Source File: EtFuturum.java From Et-Futurum with The Unlicense | 5 votes |
@EventHandler public void processIMCRequests(IMCEvent event) { for (IMCMessage message : event.getMessages()) if (message.key.equals("register-brewing-fuel")) { NBTTagCompound nbt = message.getNBTValue(); ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("Fuel")); int brews = nbt.getInteger("Brews"); BrewingFuelRegistry.registerFuel(stack, brews); } }
Example 18
Source File: BW_TileEntity_HeatedWaterPump.java From bartworks with MIT License | 5 votes |
@Override public void readFromNBT(NBTTagCompound p_145839_1_) { this.tick = p_145839_1_.getByte("tick"); this.fuel = p_145839_1_.getInteger("fuel"); this.maxfuel = p_145839_1_.getInteger("maxfuel"); this.outputstack = FluidStack.loadFluidStackFromNBT(p_145839_1_.getCompoundTag("FluidStack")); if (!p_145839_1_.getCompoundTag("ItemStack").equals(new NBTTagCompound())) this.fuelstack = ItemStack.loadItemStackFromNBT(p_145839_1_.getCompoundTag("ItemStack")); super.readFromNBT(p_145839_1_); }
Example 19
Source File: BarrelModeMobSpawn.java From ExNihiloAdscensio with MIT License | 4 votes |
@Override public void readFromNBT(NBTTagCompound tag) { progress = tag.getFloat("progress"); dollStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) tag.getTag("doll")); }
Example 20
Source File: ConsoleInputGui.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
/** * Draws the screen and all the components in it. */ @SuppressWarnings("unchecked") @Override public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) { drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE); if (this.inputField.getText().length() == 0) { this.inputField.setText("/"); } if (this.inputField.getText().charAt(0) != '/') { this.inputField.setText("/" + this.inputField.getText()); } this.inputField.drawTextBox(); IChatComponent ichatcomponent = EHacksGui.clickGui.consoleGui.getChatComponent(Mouse.getX(), Mouse.getY()); if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) { HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent(); if (null != hoverevent.getAction()) { switch (hoverevent.getAction()) { case SHOW_ITEM: ItemStack itemstack = null; try { NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText()); if (nbtbase instanceof NBTTagCompound) { itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbtbase); } } catch (NBTException ignored) { } if (itemstack != null) { this.renderToolTip(itemstack, p_73863_1_, p_73863_2_); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_73863_1_, p_73863_2_); } break; case SHOW_TEXT: this.func_146283_a(Splitter.on("\n").splitToList(hoverevent.getValue().getFormattedText()), p_73863_1_, p_73863_2_); break; case SHOW_ACHIEVEMENT: StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText()); if (statbase != null) { IChatComponent ichatcomponent1 = statbase.func_150951_e(); ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic")); chatcomponenttranslation.getChatStyle().setItalic(Boolean.TRUE); String s = statbase instanceof Achievement ? ((Achievement) statbase).getDescription() : null; ArrayList<String> arraylist = Lists.newArrayList(ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText()); if (s != null) { arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150)); } this.func_146283_a(arraylist, p_73863_1_, p_73863_2_); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_73863_1_, p_73863_2_); } break; default: break; } } GL11.glDisable(GL11.GL_LIGHTING); } super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); }