Java Code Examples for net.minecraft.nbt.NBTTagCompound#getLong()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#getLong() .
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: SpaceObjectAsteroid.java From AdvancedRocketry with MIT License | 6 votes |
@Override public void readFromNbt(NBTTagCompound nbt) { super.readFromNbt(nbt); NBTTagList list = nbt.getTagList("composition", NBT.TAG_COMPOUND); compositionMapping.clear(); for(int i = 0; i < list.tagCount(); i++) { NBTTagCompound tag = list.getCompoundTagAt(i); int blockId = tag.getInteger("id"); int rarity = tag.getInteger("amt"); compositionMapping.put(Block.getBlockById(blockId), rarity); } numberOfBlocks = nbt.getInteger("numBlocks"); uuid = nbt.getLong("uuid"); data.readFromNBT(nbt); }
Example 2
Source File: SpongeSchematic.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void readMetadataFromTag(NBTTagCompound tag) { super.readMetadataFromTag(tag); if (tag.hasKey("Metadata", Constants.NBT.TAG_COMPOUND)) { NBTTagCompound metaTag = tag.getCompoundTag("Metadata"); if (metaTag.hasKey("Date", Constants.NBT.TAG_LONG) && this.getMetadata().getTimeCreated() <= 0) { long time = metaTag.getLong("Date"); this.getMetadata().setTimeCreated(time); this.getMetadata().setTimeModified(time); } } }
Example 3
Source File: OwnerData.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
private OwnerData readFromNBT(NBTTagCompound nbt) { if (nbtHasOwnerTag(nbt) == false) { return null; } NBTTagCompound tag = nbt.hasKey("Owner", Constants.NBT.TAG_COMPOUND) ? nbt.getCompoundTag("Owner") : nbt.getCompoundTag("Player"); this.ownerUUIDMost = tag.getLong("UUIDM"); this.ownerUUIDLeast = tag.getLong("UUIDL"); this.ownerName = tag.getString("Name"); this.isPublic = tag.getBoolean("Public"); this.ownerUUID = new UUID(this.ownerUUIDMost, this.ownerUUIDLeast); return this; }
Example 4
Source File: TileEntityMoniteringStation.java From AdvancedRocketry with MIT License | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); state = RedstoneState.values()[nbt.getByte("redstoneState")]; redstoneControl.setRedstoneState(state); if(nbt.hasKey("missionID")) { long id = nbt.getLong("missionID"); int dimid = nbt.getInteger("missionDimId"); SatelliteBase sat = DimensionManager.getInstance().getSatellite(id); if(sat instanceof IMission) mission = (IMission)sat; } }
Example 5
Source File: ItemGlassesBridge.java From OpenPeripheral-Addons with MIT License | 5 votes |
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void addInformation(ItemStack stack, EntityPlayer player, List result, boolean extended) { NBTTagCompound tag = stack.getTagCompound(); if (tag != null && tag.hasKey(TileEntityGlassesBridge.TAG_GUID)) { long guid = tag.getLong(TileEntityGlassesBridge.TAG_GUID); result.add(StatCollector.translateToLocalFormatted("openperipheral.misc.key", TerminalUtils.formatTerminalId(guid))); } }
Example 6
Source File: TileObservatory.java From AdvancedRocketry with MIT License | 5 votes |
@Override protected void readNetworkData(NBTTagCompound nbt) { super.readNetworkData(nbt); openProgress = nbt.getInteger("openProgress"); isOpen = nbt.getBoolean("isOpen"); viewDistance = nbt.getInteger("viewableDist"); lastSeed = nbt.getLong("lastSeed"); lastButton = nbt.getInteger("lastButton"); lastType = nbt.getString("lastType"); }
Example 7
Source File: EntityEnderArrow.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompound) { this.blockX = tagCompound.getInteger("xTile"); this.blockY = tagCompound.getInteger("yTile"); this.blockZ = tagCompound.getInteger("zTile"); this.inBlock = Block.getBlockById(tagCompound.getInteger("inTile")); this.inData = tagCompound.getByte("inData") & 0xF; this.ticksInGround = tagCompound.getShort("life"); this.arrowShake = tagCompound.getByte("shake") & 255; this.inGround = tagCompound.getByte("inGround") == 1; if (tagCompound.hasKey("pickup", Constants.NBT.TAG_ANY_NUMERIC)) { this.canBePickedUp = tagCompound.getByte("pickup"); } else if (tagCompound.hasKey("player", Constants.NBT.TAG_ANY_NUMERIC)) { this.canBePickedUp = tagCompound.getBoolean("player") ? 1 : 0; } if (tagCompound.hasKey("shooterUUIDMost", Constants.NBT.TAG_LONG) && tagCompound.hasKey("shooterUUIDLeast", Constants.NBT.TAG_LONG)) { this.shooterUUID = new UUID(tagCompound.getLong("shooterUUIDMost"), tagCompound.getLong("shooterUUIDLeast")); this.shootingEntity = this.getEntityWorld().getPlayerEntityByUUID(this.shooterUUID); } this.tpTarget = TargetData.readTargetFromNBT(tagCompound); this.tpMode = tagCompound.getByte("tpMode"); this.applyPersistence = tagCompound.getBoolean("Persistence"); }
Example 8
Source File: PowerContainer.java From Cyberware with MIT License | 5 votes |
@Override public void deserializeNBT(NBTTagCompound nbt) { this.stored = nbt.getLong("power"); this.capacity = nbt.getLong("capacity"); this.inputRate = nbt.getLong("input"); this.outputRate = nbt.getLong("output"); if (this.stored > this.getCapacity()) { this.stored = this.getCapacity(); } }
Example 9
Source File: SpaceObjectManager.java From AdvancedRocketry with MIT License | 5 votes |
public void readFromNBT(NBTTagCompound nbt) { NBTTagList list = nbt.getTagList("spaceContents", NBT.TAG_COMPOUND); nextId = nbt.getInteger("nextInt"); nextStationTransitionTick = nbt.getLong("nextStationTransitionTick"); for(int i = 0; i < list.tagCount(); i++) { NBTTagCompound tag = list.getCompoundTagAt(i); try { ISpaceObject object = (ISpaceObject)nameToClass.get(tag.getString("type")).newInstance(); object.readFromNbt(tag); if(tag.hasKey("expireTime")) { long expireTime = tag.getLong("expireTime"); int numPlayers = tag.getInteger("numPlayers"); if (DimensionManager.getWorld(Configuration.spaceDimId).getTotalWorldTime() >= expireTime && numPlayers == 0) continue; temporaryDimensions.put(object.getId(), expireTime); temporaryDimensionPlayerNumber.put(object.getId(), numPlayers); } registerSpaceObject(object, object.getOrbitingPlanetId(), object.getId() ); } catch (Exception e) { System.out.println(tag.getString("type")); e.printStackTrace(); } } }
Example 10
Source File: SatelliteProperties.java From AdvancedRocketry with MIT License | 5 votes |
public void readFromNBT(NBTTagCompound nbt) { powerGeneration = nbt.getInteger("powerGeneration"); powerStorage = nbt.getInteger("powerStorage"); satType = nbt.getString("dataType"); id = nbt.getLong("satId"); maxData = nbt.getInteger("maxData"); }
Example 11
Source File: SyncableUUID.java From OpenModsLib with MIT License | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt, String name) { if (nbt.hasKey(name, Constants.NBT.TAG_COMPOUND)) { NBTTagCompound data = nbt.getCompoundTag(name); long msb = data.getLong("MSB"); long lsb = data.getLong("LSB"); this.uuid = new UUID(msb, lsb); } else { this.uuid = null; } }
Example 12
Source File: GT_MetaTileEntity_RadioHatch.java From bartworks with MIT License | 5 votes |
@Override public void loadNBTData(NBTTagCompound aNBT) { this.timer = aNBT.getLong("timer"); this.mass = aNBT.getByte("mMass"); this.sievert = aNBT.getByte("mSv") + 100; this.coverage = aNBT.getByte("mCoverage"); this.colorForGUI = BW_ColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); this.material = aNBT.getString("mMaterial"); super.loadNBTData(aNBT); }
Example 13
Source File: HerdPath.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public void readFromNBT(NBTTagCompound nbt, IslandMap map) { this.calcTimestamp = nbt.getLong("timestamp"); int[] pathArray = nbt.getIntArray("path"); for(int i = 0; i < pathArray.length; i++) { path.add(map.centers.get(pathArray[i])); } }
Example 14
Source File: BlockPortal.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * Called When an Entity Collided with the Block */ @Override public void onEntityCollidedWithBlock(World worldObj, BlockPos pos, IBlockState state, Entity entityIn) { /*if( !worldObj.isRemote) { if(worldObj.provider.getDimension() == 0) { entityIn.changeDimension(2); } else if(worldObj.provider.getDimension() == 2) { entityIn.changeDimension(0); } }*/ if (!entityIn.isRiding() && !entityIn.isBeingRidden() && !worldObj.isRemote) { NBTTagCompound nbt = entityIn.getEntityData().getCompoundTag("TFC2"); if(Timekeeper.getInstance().getTotalTicks() - nbt.getLong("lastPortalTime") < 1000) return; MinecraftServer minecraftserver = worldObj.getMinecraftServer(); if(worldObj.provider.getDimension() == 0) { entityIn.changeDimension(2); nbt.setLong("lastPortalTime", Timekeeper.getInstance().getTotalTicks()); } else if(worldObj.provider.getDimension() == 2) { entityIn.changeDimension(0); nbt.setLong("lastPortalTime", Timekeeper.getInstance().getTotalTicks()); } } }
Example 15
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ public Object load(NBTTagCompound tag, String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { if (tag.getBoolean(key + "::nova.isBigInteger")) { return new BigInteger(tag.getString(key)); } else if (tag.getBoolean(key + "::nova.isBigDecimal")) { return new BigDecimal(tag.getString(key)); } else { return tag.getString(key); } } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean(key + "::nova.isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example 16
Source File: GT_TileEntity_ManualTrafo.java From bartworks with MIT License | 4 votes |
@Override public void loadNBTData(NBTTagCompound ntag) { super.loadNBTData(ntag); this.mCoilWicks = ntag.getLong("mCoilWicks"); }
Example 17
Source File: SchematicMetadata.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
public void fromTag(NBTTagCompound tag) { if (tag.hasKey("Name", Constants.NBT.TAG_STRING)) { this.name = tag.getString("Name"); } if (tag.hasKey("Author", Constants.NBT.TAG_STRING)) { this.author = tag.getString("Author"); } if (tag.hasKey("Description", Constants.NBT.TAG_STRING)) { this.description = tag.getString("Description"); } if (tag.hasKey("RegionCount", Constants.NBT.TAG_INT)) { this.regionCount = tag.getInteger("RegionCount"); } if (tag.hasKey("TotalVolume", Constants.NBT.TAG_LONG) || tag.hasKey("TotalVolume", Constants.NBT.TAG_INT)) { this.totalVolume = tag.getLong("TotalVolume"); } if (tag.hasKey("TotalBlocks", Constants.NBT.TAG_LONG) || tag.hasKey("TotalBlocks", Constants.NBT.TAG_INT)) { this.totalBlocks = tag.getLong("TotalBlocks"); } if (tag.hasKey("TimeCreated", Constants.NBT.TAG_LONG)) { this.timeCreated = tag.getLong("TimeCreated"); } if (tag.hasKey("TimeModified", Constants.NBT.TAG_LONG)) { this.timeModified = tag.getLong("TimeModified"); } if (tag.hasKey("EnclosingSize", Constants.NBT.TAG_COMPOUND)) { Vec3i size = NBTUtils.readBlockPos(tag.getCompoundTag("EnclosingSize")); if (size != null) { this.enclosingSize = size; } } if (tag.hasKey("PreviewImageData", Constants.NBT.TAG_INT_ARRAY)) { this.thumbnailPixelData = tag.getIntArray("PreviewImageData"); } else { this.thumbnailPixelData = null; } }
Example 18
Source File: NBTHelper.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
public static long getLong(NBTTagCompound compound, String tag, long defaultValue) { return compound.hasKey(tag) ? compound.getLong(tag) : defaultValue; }
Example 19
Source File: EnergyContainerHandler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void deserializeNBT(NBTTagCompound compound) { this.energyStored = compound.getLong("EnergyStored"); notifyEnergyListener(true); }
Example 20
Source File: TileAnvil.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void readNonSyncableNBT(NBTTagCompound nbt) { smithID = new UUID(nbt.getLong("farmerID_least"), nbt.getLong("farmerID_most")); }