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

The following examples show how to use net.minecraft.nbt.NBTTagCompound#getDouble() . 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: LPRoutedItem.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
public static LPRoutedItem readFromNBT(NBTTagCompound compound, TileGenericPipe holder) {
	double x = compound.getDouble("posX");
	double y = compound.getDouble("posY");
	double z = compound.getDouble("posZ");
	UUID id = compound.getUniqueId("UID");
	ItemStack content = new ItemStack(compound.getCompoundTag("inventory"));
	int ticks = compound.getInteger("ticks");
	Deque<EnumFacing> routingInfo = new ArrayDeque<>();
	NBTTagList routeList = (NBTTagList) compound.getTag("route");
	for(Iterator<NBTBase> i = routeList.iterator(); i.hasNext();) {
		NBTTagCompound node = (NBTTagCompound) i.next();
		EnumFacing nodeTuple = EnumFacing.values()[node.getInteger("heading")];
		routingInfo.add(nodeTuple);
	}
	LPRoutedItem item = new LPRoutedItem(x, y, z, content, ticks, id);
	item.setHeading(EnumFacing.VALUES[compound.getInteger("heading")]);
	item.setHolding(holder);
	item.route = routingInfo;
	return item;
}
 
Example 2
Source File: GrowingNodeBehavior.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void readFromNBT(NBTTagCompound nbtTagCompound) {
    this.isSaturated = nbtTagCompound.getBoolean("overallSaturated");
    this.overallHappiness = nbtTagCompound.getDouble("overallHappiness");

    if(nbtTagCompound.hasKey("lastFed")) {
        this.lastFedAspect = Aspect.getAspect(nbtTagCompound.getString("lastFedAspect"));
        this.lastFedRow = nbtTagCompound.getInteger("lastFedRow");
    }

    NBTTagList list = nbtTagCompound.getTagList("saturationValues", 10);
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound aspectCompound = list.getCompoundTagAt(i);
        String name = aspectCompound.getString("aspectName");
        double saturation = aspectCompound.getDouble("aspectSaturation");
        Aspect a = Aspect.getAspect(name);
        if(a != null) {
            aspectSaturation.put(a, saturation);
        }
    }
}
 
Example 3
Source File: HeatExchangerLogic.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    temperature = tag.getDouble("temperature");
    behaviours.clear();
    NBTTagList tagList = tag.getTagList("behaviours", 10);
    for(int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound t = tagList.getCompoundTagAt(i);
        HeatBehaviour behaviour = HeatBehaviourManager.getInstance().getBehaviourForId(t.getString("id"));
        if(behaviour != null) {
            behaviour.readFromNBT(t);
            behaviours.add(behaviour);
        }
    }
}
 
Example 4
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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
 */
@Nullable
public Object load(@Nullable NBTTagCompound tag, @Nullable 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) {
			return tag.getString(key);
		} else if (saveTag instanceof NBTTagShort) {
			return tag.getShort(key);
		} else if (saveTag instanceof NBTTagByte) {
			if (tag.getBoolean("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 5
Source File: FixedPointUtils.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static float getFixedFromNBT(NBTTagCompound nbt, String key) {
	// See net.minecraft.nbt.NBTBase.NBT_TYPES[] for meaning of type ids.

	byte dataType = nbt.getTagId(key);
	if (dataType == Constants.NBT.TAG_DOUBLE)
		return (float) nbt.getDouble(key);    // NOTE: For legacy case
	else if (dataType == Constants.NBT.TAG_FLOAT) // byte, short, int, long, float
		return nbt.getFloat(key);
	else if (dataType == Constants.NBT.TAG_LONG)
		return fixedToDouble(nbt.getLong(key));
	return 0;
}
 
Example 6
Source File: MissionResourceCollection.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	
	missionPersistantNBT = nbt.getCompoundTag("persist" );

	rocketStats = new StatsRocket();
	rocketStats.readFromNBT(nbt.getCompoundTag("rocketStats"));

	rocketStorage = new StorageChunk();
	rocketStorage.readFromNBT(nbt.getCompoundTag("rocketStorage"));

	x = nbt.getDouble("launchPosX");
	y = nbt.getDouble("launchPosY");
	z = nbt.getDouble("launchPosZ");

	startWorldTime = nbt.getLong("startWorldTime");
	duration = nbt.getLong("duration");
	worldId = nbt.getInteger("startDimid");
	launchDimension = nbt.getInteger("launchDim");

	NBTTagList tagList = nbt.getTagList("infrastructure", 10);
	infrastructureCoords.clear();

	for (int i = 0; i < tagList.tagCount(); i++) {
		int coords[] = tagList.getCompoundTagAt(i).getIntArray("loc");
		infrastructureCoords.add(new HashedBlockPosition(coords[0], coords[1], coords[2]));
	}
}
 
Example 7
Source File: SlimeBlock.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
	NBTTagCompound data = entity.getEntityData();
	if (data.hasKey(Reference.MOD_ID + ":slime")) {
		entity.motionY = data.getDouble(Reference.MOD_ID + ":slime");
		data.removeTag(Reference.MOD_ID + ":slime");
	}

	if (Math.abs(entity.motionY) < 0.1 && !entity.isSneaking()) {
		double d = 0.4 + Math.abs(entity.motionY) * 0.2;
		entity.motionX *= d;
		entity.motionZ *= d;
	}
}
 
Example 8
Source File: TileRocketBuilder.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);

	stats.readFromNBT(nbt);

	prevProgress = progress = nbt.getInteger("scanTime");
	totalProgress = nbt.getInteger("scanTotalBlocks");
	status = ErrorCodes.values()[nbt.getInteger("status")];

	building = nbt.getBoolean("building");
	if(nbt.hasKey("bb")) {

		NBTTagCompound tag = nbt.getCompoundTag("bb");
		bbCache = new AxisAlignedBB(tag.getDouble("minX"), 
				tag.getDouble("minY"), tag.getDouble("minZ"),
				tag.getDouble("maxX"), tag.getDouble("maxY"), tag.getDouble("maxZ"));

	}

	blockPos.clear();
	if(nbt.hasKey("infrastructureLocations")) {
		int array[] = nbt.getIntArray("infrastructureLocations");

		for(int counter = 0; counter < array.length; counter += 3) {
			blockPos.add(new HashedBlockPosition(array[counter], array[counter+1], array[counter+2]));
		}
	}
}
 
Example 9
Source File: TileEntityLiftLever.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    leverOffset = compound.getFloat("leverOffset");
    targetYPosition = compound.getDouble("targetYPosition");
    hasHeightBeenSet = compound.getBoolean("hasHeightBeenSet");
}
 
Example 10
Source File: Edge.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt, IslandMap m)
{
	this.midpoint = new Point(nbt.getDouble("midX"), nbt.getDouble("midY"));
	dCenter0 = m.centers.get(nbt.getInteger("dcenter0"));
	dCenter1 = m.centers.get(nbt.getInteger("dcenter1"));
	vCorner0 = m.corners.get(nbt.getInteger("vCorner0"));
	vCorner1 = m.corners.get(nbt.getInteger("vCorner1"));
}
 
Example 11
Source File: EntityMountable.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
protected void readEntityFromNBT(NBTTagCompound compound) {
    mountPos = new Vec3d(compound.getDouble("vs_mount_pos_x"),
        compound.getDouble("vs_mount_pos_y"), compound.getDouble("vs_mount_pos_z"));
    mountPosSpace = CoordinateSpaceType.values()[compound.getInteger("vs_coord_type")];

    if (compound.getBoolean("vs_ref_pos_present")) {
        referencePos = new BlockPos(compound.getInteger("vs_ref_pos_x"),
            compound.getInteger("vs_ref_pos_y"), compound.getInteger("vs_ref_pos_z"));
    } else {
        referencePos = null;
    }
}
 
Example 12
Source File: IslandParameters.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt)
{
	NBTTagCompound fnbt = nbt.getCompoundTag("features");
	for(Feature f : Feature.values())
	{
		if(fnbt.hasKey(f.toString()))
			features.add(f);
	}
	this.setCoords(nbt.getInteger("xCoord"), nbt.getInteger("zCoord"));
	this.oceanRatio = nbt.getDouble("oceanRatio");
	this.lakeThreshold = nbt.getDouble("lakeThreshold");
	this.islandMaxHeight = nbt.getDouble("islandMaxHeight");
	this.surfaceRock = StoneType.getStoneTypeFromMeta(nbt.getInteger("surfaceRock"));
	this.treeCommon = nbt.getString("treeCommon");
	this.treeUncommon = nbt.getString("treeUncommon");
	this.treeRare = nbt.getString("treeRare");
	this.moisture = Moisture.values()[nbt.getInteger("moisture")];
	this.temp = ClimateTemp.values()[nbt.getInteger("temp")];
	this.seed = nbt.getLong("seed");

	this.animalTypes = new ArrayList<String>();
	String animals = nbt.getString("animalTypes");
	String[] split = animals.split(",");
	for(int i = 0; i < split.length; i++)
	{
		animalTypes.add(split[i]);
	}

	cropList.clear();
	int[] cropArray = nbt.getIntArray("crops");
	for(int i = 0; i < cropArray.length; i++)
	{
		cropList.add(Crop.fromID(cropArray[i]));
	}
}
 
Example 13
Source File: LakeAttribute.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt, com.bioxx.jmapgen.IslandMap m) 
{
	this.id = UUID.fromString(nbt.getString("uuid"));
	this.lakeID = nbt.getInteger("lakeID");
	this.borderDistance = nbt.getInteger("borderDistance");
	this.isMarsh = nbt.getBoolean("isMarsh");
	this.lakeElev = nbt.getDouble("lakeElev");
}
 
Example 14
Source File: ValkyrienNBTUtils.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public static AxisAlignedBB readAABBFromNBT(String name, NBTTagCompound compound) {
    AxisAlignedBB aabb = new AxisAlignedBB(compound.getDouble(name + "minX"),
        compound.getDouble(name + "minY"),
        compound.getDouble(name + "minZ"), compound.getDouble(name + "maxX"),
        compound.getDouble(name + "maxY"),
        compound.getDouble(name + "maxZ"));
    return aabb;
}
 
Example 15
Source File: TileElectricGenerator.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    this.energy = nbt.getDouble("energy");
}
 
Example 16
Source File: TileEntityMEBattery.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt)
{
	super.readFromNBT(nbt);
	energy = nbt.getDouble("storedEnergy");
}
 
Example 17
Source File: HeatBehaviourLiquidTransition.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    extractedHeat = tag.getDouble("extractedHeat");
}
 
Example 18
Source File: NbtUtils.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static Vec3d readVec(NBTTagCompound tag) {
	final double x = tag.getDouble(TAG_X);
	final double y = tag.getDouble(TAG_Y);
	final double z = tag.getDouble(TAG_Z);
	return new Vec3d(x, y, z);
}
 
Example 19
Source File: TileElectricContainer.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    this.energy = nbt.getDouble("energy");
}
 
Example 20
Source File: PowerHandler.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public void readFromNBT(NBTTagCompound data, String tag) {
	NBTTagCompound nbt = data.getCompoundTag(tag);
	energyStored = nbt.getDouble("energyStored");
}