Java Code Examples for net.minecraft.nbt.NBTTagCompound#setLong()

The following examples show how to use net.minecraft.nbt.NBTTagCompound#setLong() . 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: SpaceObjectManager.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt) {
	Iterator<ISpaceObject> iterator = stationLocations.values().iterator();
	NBTTagList nbtList = new NBTTagList();

	while(iterator.hasNext()) {
		ISpaceObject object = iterator.next();
		NBTTagCompound nbtTag = new NBTTagCompound();
		object.writeToNbt(nbtTag);
		
		nbtTag.setString("type", classToString.get(object.getClass()));
		if(temporaryDimensions.containsKey(object.getId())) {
			nbtTag.setLong("expireTime", temporaryDimensions.get(object.getId()));
			nbtTag.setInteger("numPlayers", temporaryDimensionPlayerNumber.get(object.getId()));
		}
		
		nbtList.appendTag(nbtTag);
	}
	
	
	nbt.setTag("spaceContents", nbtList);
	nbt.setInteger("nextInt", nextId);
	nbt.setLong("nextStationTransitionTick", nextStationTransitionTick);
}
 
Example 2
Source File: SpaceObjectAsteroid.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void writeToNbt(NBTTagCompound nbt) {
	super.writeToNbt(nbt);
	
	NBTTagList list = new NBTTagList();
	for(Entry<Block, Integer> entry : compositionMapping.entrySet()) {
		NBTTagCompound tag = new NBTTagCompound();
		tag.setInteger("id", Block.getIdFromBlock(entry.getKey()));
		tag.setInteger("amt", entry.getValue());
		list.appendTag(tag);
	}
	nbt.setTag("composition", list);
	nbt.setInteger("numBlocks", numberOfBlocks);
	nbt.setLong("uuid",uuid);
	data.writeToNBT(nbt);
}
 
Example 3
Source File: TileEntityDisplayPedestal.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag)
{
	super.writeToNBT(tag);
	NBTTagList nbttaglist = new NBTTagList();

	if (this.contents != null)
	{
		NBTTagCompound nbttagcompound1 = new NBTTagCompound();
		nbttagcompound1.setByte("Slot", (byte) 0);
		this.contents.writeToNBT(nbttagcompound1);
		nbttaglist.appendTag(nbttagcompound1);
	}

	tag.setTag("Items", nbttaglist);
	tag.setString("OwnerName", ownerName);
	tag.setLong("OwnerUUIDLeast", ownerUUID.getLeastSignificantBits());
	tag.setLong("OwnerUUIDMost", ownerUUID.getMostSignificantBits());
	tag.setInteger("rotation", rotation);
}
 
Example 4
Source File: TileEntityMonitorStorageFluid.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
public Packet getDescriptionPacket()
{
	NBTTagCompound nbtTag = getColorDataForPacket();
	writeToNBT(nbtTag);
	nbtTag.setBoolean("networkReady", networkReady);
	nbtTag.setBoolean("powerStatus", powerStatus);
	nbtTag.setLong("amount", fluidAmount);
	nbtTag.setInteger("meta", getBlockMetadata());
	return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}
 
Example 5
Source File: PowerContainer.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public NBTTagCompound serializeNBT()
{
	final NBTTagCompound tag = new NBTTagCompound();
	tag.setLong("power", stored);
	tag.setLong("capacity", capacity);
	tag.setLong("input", inputRate);
	tag.setLong("output", outputRate);
	
	return tag;
}
 
Example 6
Source File: TileCrop.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void writeNonSyncableNBT(NBTTagCompound nbt)
{
	nbt.setBoolean("isWild", isWild);
	nbt.setLong("plantedTimeStamp", plantedTimeStamp);
	nbt.setLong("farmerID_least", this.farmerID.getLeastSignificantBits());
	nbt.setLong("farmerID_most", this.farmerID.getMostSignificantBits());
	nbt.setInteger("hexID", hexID);
}
 
Example 7
Source File: SatelliteProperties.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt) {
	nbt.setInteger("powerGeneration", powerGeneration);
	nbt.setInteger("powerStorage", powerStorage);
	nbt.setString("dataType", satType);
	nbt.setLong("satId", id);
	nbt.setInteger("maxData", maxData);
}
 
Example 8
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Saves an unknown object to NBT
 * @param tag - NBTTagCompound to queueSave the tag too
 * @param key - name to queueSave the object as
 * @param value - the actual object
 * @return the tag when done saving too i
 */
@Nonnull
public NBTTagCompound save(@Nonnull NBTTagCompound tag, @Nonnull String key, @Nullable Object value) {
	if (value instanceof Boolean) {
		tag.setBoolean("isBoolean", true);
		tag.setBoolean(key, (boolean) value);
	} else if (value instanceof Byte) {
		tag.setBoolean("isBoolean", false);
		tag.setByte(key, (byte) value);
	} else if (value instanceof Short) {
		tag.setShort(key, (short) value);
	} else if (value instanceof Integer) {
		tag.setInteger(key, (int) value);
	} else if (value instanceof Long) {
		tag.setLong(key, (long) value);
	} else if (value instanceof Character) {
		tag.setInteger(key, (Character) value);
	} else if (value instanceof Float) {
		tag.setFloat(key, (float) value);
	} else if (value instanceof Double) {
		tag.setDouble(key, (double) value);
	} else if (value instanceof String) {
		tag.setString(key, (String) value);
	} else if (value instanceof Data) {
		NBTTagCompound innerTag = new NBTTagCompound();
		toNative(innerTag, (Data) value);
		tag.setTag(key, innerTag);
	}
	return tag;
}
 
Example 9
Source File: TileEntityQuickStackerAdvanced.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
    super.writeToNBT(nbt);

    nbt.setBoolean("AreaMode", this.isAreaMode());
    nbt.setByte("EnabledTargets", (byte) this.enabledTargetsMask);
    nbt.setByte("SelectedTarget", this.selectedTarget);
    nbt.setLong("EnabledSlots", this.slotMask);
    nbt.merge(this.filtersAreaMode.serializeNBT());

    return nbt;
}
 
Example 10
Source File: EnderUtilitiesCapabilities.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTBase writeNBT(Capability<T> capability, T instance, EnumFacing side)
{
    if ((instance instanceof IPortalCooldownCapability) == false)
    {
        throw new RuntimeException(instance.getClass().getName() + " does not implement IPortalCooldownCapability");
    }

    NBTTagCompound nbt = new NBTTagCompound();
    IPortalCooldownCapability cap = (IPortalCooldownCapability) instance;
    nbt.setLong("LastInPortal", cap.getLastInPortalTime());

    return nbt;
}
 
Example 11
Source File: GT_MetaTileEntity_RadioHatch.java    From bartworks with MIT License 5 votes vote down vote up
@Override
public void saveNBTData(NBTTagCompound aNBT) {
    aNBT.setByte("mMass", this.mass);
    aNBT.setByte("mSv", (byte) (this.sievert - 100));
    aNBT.setByte("mCoverage", this.coverage);
    aNBT.setInteger("mTextColor", BW_ColorUtil.getColorFromRGBArray(this.getColorForGUI()));
    if (this.material != null && !this.material.isEmpty())
        aNBT.setString("mMaterial", this.material);
    aNBT.setLong("timer", this.timer);
    super.saveNBTData(aNBT);
}
 
Example 12
Source File: TileEntityLevelEmitterFluid.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public Packet getDescriptionPacket()
{
	NBTTagCompound nbtTag = getColorDataForPacket();
	this.writeToNBT(nbtTag);

	nbtTag.setLong("currentAmount", currentAmount);
	nbtTag.setLong("filterAmount", filterAmount);

	return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}
 
Example 13
Source File: MetaTileEntityLockedSafe.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
    data = super.writeToNBT(data);
    data.setInteger("UnlockProgress", unlockProgress);
    data.setInteger("ComponentTier", unlockComponentTier);
    data.setBoolean("Unlocked", isSafeUnlocked);

    data.setLong("UnlockComponentsSeed", unlockComponentsSeed);
    data.setTag("UnlockInventory", unlockInventory.serializeNBT());
    data.setTag("LootInventory", safeLootInventory.serializeNBT());
    return data;
}
 
Example 14
Source File: TileEntityGnode.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
    * 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;
   }
 
Example 15
Source File: GT_TileEntity_ManualTrafo.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void saveNBTData(NBTTagCompound ntag) {
    ntag.setLong("mCoilWicks", this.mCoilWicks);
    super.saveNBTData(ntag);
}
 
Example 16
Source File: GT_MetaTileEntity_Diode.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void saveNBTData(NBTTagCompound aNBT) {
    super.saveNBTData(aNBT);
    aNBT.setLong("maxAmp", this.maxAmps);
    aNBT.setLong("Amps", this.aAmps);
}
 
Example 17
Source File: NbtGuidProviders.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
public static void setTerminalGuid(ItemStack stack, Optional<Long> guid) {
	final NBTTagCompound terminalTag = getOrCreateTerminalTag(stack);
	if (guid.isPresent()) terminalTag.setLong(GUID_TAG, guid.get());
}
 
Example 18
Source File: EnergyContainerHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound compound = new NBTTagCompound();
    compound.setLong("EnergyStored", energyStored);
    return compound;
}
 
Example 19
Source File: NbtUtils.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static NBTTagCompound store(NBTTagCompound tag, UUID uuid) {
	tag.setLong("UUIDMost", uuid.getMostSignificantBits());
	tag.setLong("UUIDLeast", uuid.getLeastSignificantBits());
	return tag;
}
 
Example 20
Source File: EntityPortal.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
	nbt.setInteger("Dimension", getTarget());
	nbt.setLong("lifetime", lifetime);
}