net.minecraft.nbt.NBTTagCompound Java Examples
The following examples show how to use
net.minecraft.nbt.NBTTagCompound.
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: TileEntityShoji.java From Sakura_mod with MIT License | 6 votes |
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("type")) { type = compound.getInteger("type"); } if (compound.hasKey("facing")) { facing = EnumFacing.byName(compound.getString("facing")); } if (compound.hasKey("open")) { open = compound.getBoolean("open"); } if (compound.hasKey("animation")) { animation = compound.getInteger("animation"); } }
Example #2
Source File: ItemGPSTool.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void addInformation(ItemStack stack, EntityPlayer player, List infoList, boolean par4){ super.addInformation(stack, player, infoList, par4); NBTTagCompound compound = stack.stackTagCompound; if(compound != null) { int x = compound.getInteger("x"); int y = compound.getInteger("y"); int z = compound.getInteger("z"); if(x != 0 || y != 0 || z != 0) { infoList.add("\u00a72Set to " + x + ", " + y + ", " + z); } String varName = getVariable(stack); if(!varName.equals("")) { infoList.add(I18n.format("gui.tooltip.gpsTool.variable", varName)); } } }
Example #3
Source File: MoCEntityWyvern.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
@Override public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); setRideable(nbttagcompound.getBoolean("Saddle")); setIsChested(nbttagcompound.getBoolean("Chested")); setArmorType(nbttagcompound.getByte("ArmorType")); setSitting(nbttagcompound.getBoolean("isSitting")); if (getIsChested()) { NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); localchest = new MoCAnimalChest("WyvernChest", 14); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xff; if ((j >= 0) && j < localchest.getSizeInventory()) { localchest.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound1)); } } } }
Example #4
Source File: SafariNetMetaProvider.java From OpenPeripheral-Integration with MIT License | 6 votes |
@Override public Object getMeta(Item target, ItemStack stack) { Map<String, Object> result = Maps.newHashMap(); String type = safariNets.get(target.getUnlocalizedName()); result.put("type", Objects.firstNonNull(type, "unknown")); NBTTagCompound tag = stack.getTagCompound(); if (tag != null) { if (tag.getBoolean("hide")) { result.put("captured", "?"); } else if (tag.hasKey("id", Constants.NBT.TAG_STRING)) { result.put("captured", tag.getString("id")); } } return result; }
Example #5
Source File: ItemBlockEUStorage.java From Production-Line with MIT License | 6 votes |
/** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @SideOnly(Side.CLIENT) @Override public void getSubItems(@Nonnull Item item, @Nonnull CreativeTabs creativeTabs, @Nonnull List<ItemStack> list) { super.getSubItems(item, creativeTabs, list); ItemStack itemStack; NBTTagCompound nbt; itemStack = PLBlocks.evsu.copy(); nbt = StackUtil.getOrCreateNbtData(itemStack); nbt.setInteger("energy", (int) 1E8); list.add(itemStack); itemStack = PLBlocks.cseu.copy(); nbt = StackUtil.getOrCreateNbtData(itemStack); nbt.setInteger("energy", (int) 720E3); list.add(itemStack); itemStack = PLBlocks.parallelSpaceSU.copy(); nbt = StackUtil.getOrCreateNbtData(itemStack); nbt.setInteger("energy", (int) 2E8); list.add(itemStack); }
Example #6
Source File: BWBlockTransform.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void setWorld(World world) { net.minecraft.world.World oldWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(this.world); net.minecraft.world.World newWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(world); Optional<TileEntity> tileEntity = Optional.ofNullable(oldWorld.getTileEntity((int) position.getX(), (int) position.getY(), (int) position.getZ())); Optional<NBTTagCompound> nbt = Optional.empty(); if (tileEntity.isPresent()) { NBTTagCompound compound = new NBTTagCompound(); tileEntity.get().writeToNBT(compound); nbt = Optional.of(compound); } newWorld.setBlock((int) position.getX(), (int) position.getY(), (int) position.getZ(), block.mcBlock, block.getMetadata(), 3); oldWorld.removeTileEntity((int) position.getX(), (int) position.getY(), (int) position.getZ()); oldWorld.setBlockToAir((int) position.getX(), (int) position.getY(), (int) position.getZ()); Optional<TileEntity> newTileEntity = Optional.ofNullable(newWorld.getTileEntity((int) position.getX(), (int) position.getY(), (int) position.getZ())); if (newTileEntity.isPresent() && nbt.isPresent()) { newTileEntity.get().readFromNBT(nbt.get()); } this.world = world; }
Example #7
Source File: StandardWizardryWorld.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public NBTTagCompound serializeNBT() { NBTTagCompound compound = new NBTTagCompound(); compound.setTag("spell_object_manager", spellObjectManager.manager.toNbt()); NBTTagList driveNBT = new NBTTagList(); for (Map.Entry<BlockPos, NemezTracker> entry : blockNemezDrives.entrySet()) { if (entry == null) continue; NBTTagCompound compound1 = new NBTTagCompound(); compound1.setLong("pos", entry.getKey().toLong()); compound1.setTag("drive", entry.getValue().serializeNBT()); driveNBT.appendTag(compound1); } compound.setTag("drives", driveNBT); return compound; }
Example #8
Source File: TileEntityBeefBase.java From BigReactors with MIT License | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); // Rotation if(tag.hasKey("facing")) { facing = Math.max(0, Math.min(5, tag.getInteger("facing"))); } else { facing = 2; } // Exposure settings if(tag.hasKey("exposures")) { int[] tagExposures = tag.getIntArray("exposures"); assert(tagExposures.length == exposures.length); System.arraycopy(tagExposures, 0, exposures, 0, exposures.length); } }
Example #9
Source File: CraftOfflinePlayer.java From Kettle with GNU General Public License v3.0 | 6 votes |
public String getName() { Player player = getPlayer(); if (player != null) { return player.getName(); } // This might not match lastKnownName but if not it should be more correct if (profile.getName() != null) { return profile.getName(); } NBTTagCompound data = getBukkitData(); if (data != null) { if (data.hasKey("lastKnownName")) { return data.getString("lastKnownName"); } } return null; }
Example #10
Source File: CyberwareDataHandler.java From Cyberware with MIT License | 6 votes |
@SubscribeEvent public void startTrackingEvent(StartTracking event) { EntityPlayer tracker = event.getEntityPlayer(); Entity target = event.getTarget(); if (!target.worldObj.isRemote) { if (CyberwareAPI.hasCapability(target)) { if (target instanceof EntityPlayer) { //System.out.println("Sent data for player " + ((EntityPlayer) target).getName() + " to player " + tracker.getName()); } NBTTagCompound nbt = CyberwareAPI.getCapability(target).serializeNBT(); CyberwarePacketHandler.INSTANCE.sendTo(new CyberwareSyncPacket(nbt, target.getEntityId()), (EntityPlayerMP) tracker); } } }
Example #11
Source File: AmadronOfferCustom.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); tag.setString("offeringPlayerId", offeringPlayerId); tag.setString("offeringPlayerName", offeringPlayerName); tag.setInteger("inStock", inStock); tag.setInteger("maxTrades", maxTrades); tag.setInteger("pendingPayments", pendingPayments); if(providingPosition != null) { tag.setInteger("providingDimensionId", providingDimensionId); tag.setInteger("providingX", providingPosition.chunkPosX); tag.setInteger("providingY", providingPosition.chunkPosY); tag.setInteger("providingZ", providingPosition.chunkPosZ); } if(returningPosition != null) { tag.setInteger("returningDimensionId", returningDimensionId); tag.setInteger("returningX", returningPosition.chunkPosX); tag.setInteger("returningY", returningPosition.chunkPosY); tag.setInteger("returningZ", returningPosition.chunkPosZ); } }
Example #12
Source File: LPRoutedItem.java From Logistics-Pipes-2 with MIT License | 6 votes |
public NBTTagCompound writeToNBT() { NBTTagCompound tag = new NBTTagCompound(); Triple<Double, Double, Double> pos = getPosition(); tag.setDouble("posX", pos.getFirst()); tag.setDouble("posY", pos.getSecnd()); tag.setDouble("posZ", pos.getThird()); tag.setInteger("heading", heading.ordinal()); tag.setUniqueId("UID", this.ID); tag.setTag("inventory", stack.serializeNBT()); tag.setInteger("ticks", this.ticks); NBTTagList routeList = new NBTTagList(); for(EnumFacing node : route) { NBTTagCompound nodeTag = new NBTTagCompound(); //nodeTag.setUniqueId("UID", node.getKey()); nodeTag.setInteger("heading", node.ordinal()); routeList.appendTag(nodeTag); } tag.setTag("route", routeList); return tag; }
Example #13
Source File: ItemStackMap.java From NotEnoughItems with MIT License | 5 votes |
public void addKeys(Item item, List<ItemStack> list) { if (wildcard != null) list.add(wildcard(item)); if (damageMap != null) for (int damage : damageMap.keySet()) list.add(newItemStack(item, 1, damage, WILDCARD_TAG)); if (tagMap != null) for (NBTTagCompound tag : tagMap.keySet()) list.add(newItemStack(item, 1, WILDCARD_VALUE, tag)); if (metaMap != null) for (StackMetaKey key : metaMap.keySet()) list.add(newItemStack(item, 1, key.damage, key.tag)); }
Example #14
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public CompoundTag getTag(TileEntity tile) { try { NBTTagCompound tag = new NBTTagCompound(); tile.writeToNBT(tag); // readTagIntoEntity CompoundTag result = (CompoundTag) methodToNative.invoke(null, tag); return result; } catch (Exception e) { MainUtil.handleError(e); return null; } }
Example #15
Source File: OverrideRidingEntity.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public OverrideRidingEntity(EntityGolemBase golem, NBTTagCompound compound, Entity ridingEntity) { super(golem.worldObj); Entity.nextEntityID--; this.golem = golem; this.compound = compound; this.ridingEntity = ridingEntity; }
Example #16
Source File: GolemUpgradeRunicShield.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private int getLastDischarge(EntityGolemBase golem) { NBTTagCompound compound = golem.getEntityData(); if(!compound.hasKey(LAST_DISCHARGE_TAG)) { compound.setInteger(LAST_DISCHARGE_TAG, golem.ticksExisted); return golem.ticksExisted; } return compound.getInteger(LAST_DISCHARGE_TAG); }
Example #17
Source File: LitematicaSchematic.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean fromTag(NBTTagCompound tag) { this.clear(); if (tag.hasKey("Version", Constants.NBT.TAG_INT)) { final int version = tag.getInteger("Version"); if (version >= 1 && version <= SCHEMATIC_VERSION) { this.readMetadataFromTag(tag); this.readSubRegionsFromTag(tag, version); return true; } else { InfoUtils.showGuiOrInGameMessage(MessageType.ERROR, "litematica.error.schematic_load.unsupported_schematic_version", version); } } else { InfoUtils.showGuiOrInGameMessage(MessageType.ERROR, "litematica.error.schematic_load.no_schematic_version_information"); } return false; }
Example #18
Source File: GTTileBaseRecolorableTile.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public List<ItemStack> getDrops() { List<ItemStack> drops = new ArrayList<>(); ItemStack block = GTMaterialGen.get(getBlockDrop()); if (this.isColored()) { NBTTagCompound nbt = StackUtil.getOrCreateNbtData(block); nbt.setInteger(NBT_COLOR, this.color); } drops.addAll(getInventoryDrops()); drops.add(block); return drops; }
Example #19
Source File: LakeAttribute.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public void writeToNBT(NBTTagCompound nbt) { nbt.setString("uuid", id.toString()); nbt.setInteger("lakeID", lakeID); nbt.setInteger("borderDistance", borderDistance); nbt.setBoolean("isMarsh", isMarsh); nbt.setDouble("lakeElev", lakeElev); }
Example #20
Source File: MultiblockReactor.java From BigReactors with MIT License | 5 votes |
@Override public void readFromNBT(NBTTagCompound data) { if(data.hasKey("reactorActive")) { setActive(data.getBoolean("reactorActive")); } if(data.hasKey("heat")) { setReactorHeat(Math.max(getReactorHeat(), data.getFloat("heat"))); } if(data.hasKey("storedEnergy")) { setEnergyStored(Math.max(getEnergyStored(), data.getFloat("storedEnergy"))); } if(data.hasKey("wasteEjection2")) { this.wasteEjection = s_EjectionSettings[data.getInteger("wasteEjection2")]; } if(data.hasKey("fuelHeat")) { setFuelHeat(data.getFloat("fuelHeat")); } if(data.hasKey("fuelContainer")) { fuelContainer.readFromNBT(data.getCompoundTag("fuelContainer")); } if(data.hasKey("radiation")) { radiationHelper.readFromNBT(data.getCompoundTag("radiation")); } if(data.hasKey("coolantContainer")) { coolantContainer.readFromNBT(data.getCompoundTag("coolantContainer")); } }
Example #21
Source File: ItemBrainUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent public void handleClone(PlayerEvent.Clone event) { if (event.isWasDeath()) { EntityPlayer p = event.getOriginal(); if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 0)) && !p.worldObj.getGameRules().getBoolean("keepInventory")) { /*float range = 5F; List<EntityXPOrb> orbs = p.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(p.posX - range, p.posY - range, p.posZ - range, p.posX + p.width + range, p.posY + p.height + range, p.posZ + p.width + range)); for (EntityXPOrb orb : orbs) { orb.setDead(); }*/ if (!p.worldObj.isRemote) { ItemStack stack = new ItemStack(CyberwareContent.expCapsule); NBTTagCompound c = new NBTTagCompound(); c.setInteger("xp", p.experienceTotal); stack.setTagCompound(c); EntityItem item = new EntityItem(p.worldObj, p.posX, p.posY, p.posZ, stack); p.worldObj.spawnEntityInWorld(item); } } else if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 2)) && !p.worldObj.getGameRules().getBoolean("keepInventory")) { event.getEntityPlayer().addExperience((int) (Math.min(100, p.experienceLevel * 7) * .9F)); } } }
Example #22
Source File: SpellData.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public NBTTagCompound serializeNBT() { NBTTagCompound compound = new NBTTagCompound(); for (Entry<DataField<?>, Object> entry : data.entrySet()) { NBTBase nbtClass = entry.getKey().getDataTypeProcess().serialize(entry.getValue()); compound.setTag(entry.getKey().getFieldName(), nbtClass); } return compound; }
Example #23
Source File: NBTUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Cycle a byte value in the given ItemStack's NBT in a tag <b>tagName</b>. If <b>containerTagName</b> * is not null, then the value is stored inside a compound tag by that name. * The low end of the range is 0. */ public static void cycleByteValue(@Nonnull ItemStack stack, @Nullable String containerTagName, @Nonnull String tagName, int maxValue, boolean reverse) { NBTTagCompound nbt = getCompoundTag(stack, containerTagName, true); cycleByteValue(nbt, tagName, 0, maxValue, reverse); }
Example #24
Source File: BlockInfo.java From ExNihiloAdscensio with MIT License | 5 votes |
public static BlockInfo readFromNBT(NBTTagCompound tag) { Block item_ = Block.REGISTRY.getObject(new ResourceLocation(tag.getString("block"))); int meta_ = tag.getInteger("meta"); return new BlockInfo(item_, meta_); }
Example #25
Source File: SolarGlassTileEntity.java From EmergingTechnology with MIT License | 5 votes |
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.energyHandler.readFromNBT(compound); this.setEnergy(compound.getInteger("GuiEnergy")); }
Example #26
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public Mirror getMirror(ItemStack stack, Mode mode) { int sel = this.getSelectionIndex(stack); NBTTagCompound tag = this.getModeTag(stack, mode); if (tag.getBoolean("IsMirrored_" + sel) && tag.hasKey("Mirror_" + sel, Constants.NBT.TAG_BYTE)) { return Mirror.values()[tag.getByte("Mirror_" + sel) % Mirror.values().length]; } return Mirror.NONE; }
Example #27
Source File: MetaTileEntity.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
/** * Called from ItemBlock to initialize this MTE with data contained in ItemStack * * @param itemStack itemstack of itemblock */ public void initFromItemStackData(NBTTagCompound itemStack) { if (itemStack.hasKey("PaintingColor", NBT.TAG_INT)) { setPaintingColor(itemStack.getInteger("PaintingColor")); } if (itemStack.hasKey("Fragile")) { setFragile(itemStack.getBoolean("Fragile")); } }
Example #28
Source File: ItemUtils.java From OpenModsLib with MIT License | 5 votes |
/** * This function returns fingerprint of NBTTag. It can be used to compare two tags */ public static String getNBTHash(NBTTagCompound tag) { try { MessageDigest digest = MessageDigest.getInstance("MD5"); OutputStream dump = new NullOutputStream(); DigestOutputStream hasher = new DigestOutputStream(dump, digest); DataOutput output = new DataOutputStream(hasher); CompressedStreamTools.write(tag, output); byte[] hash = digest.digest(); return new String(Hex.encodeHex(hash)); } catch (IOException | NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
Example #29
Source File: StructureTofuMineshaftPieces.java From TofuCraftReload with MIT License | 5 votes |
/** * (abstract) Helper method to write subclass data to NBT */ protected void writeStructureToNBT(NBTTagCompound tagCompound) { super.writeStructureToNBT(tagCompound); NBTTagList nbttaglist = new NBTTagList(); for (StructureBoundingBox structureboundingbox : this.connectedRooms) { nbttaglist.appendTag(structureboundingbox.toNBTTagIntArray()); } tagCompound.setTag("Entrances", nbttaglist); }
Example #30
Source File: TileEntityGnode.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
/** * Writes a tile entity to NBT. * @return */ @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagCompound compound = super.writeToNBT(nbt); nbt.setLong("buildseed", this.buildseed); return compound; }