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

The following examples show how to use net.minecraft.nbt.NBTTagCompound#setFloat() . 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: TileEntityElectricCompressor.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound){

    super.writeToNBT(nbtTagCompound);
    nbtTagCompound.setInteger("redstoneMode", redstoneMode);
    nbtTagCompound.setBoolean("outputTimer", outputTimer > 0);
    nbtTagCompound.setFloat("turbineSpeed", turbineSpeed);
    nbtTagCompound.setInteger("energyProduction", lastEnergyProduction);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    nbtTagCompound.setTag("Items", tagList);
}
 
Example 2
Source File: TileEntityAssemblyIOUnit.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag){
    super.writeToNBT(tag);
    tag.setFloat("clawProgress", clawProgress);
    tag.setBoolean("clawClosing", shouldClawClose);
    tag.setByte("state", state);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    tag.setTag("Items", tagList);
}
 
Example 3
Source File: TileEntityGearbox.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
    NBTTagCompound tagToSend = new NBTTagCompound();
    tagToSend.setDouble("rotation", rotation);
    tagToSend.setShort("input_facing", (byte) inputFacing.ordinal());
    byte validSides = 0;
    for (int i = 0; i < 6; i++) {
        if (connectedSidesRatios[i].isPresent()) {
            validSides |= 1 << i;
            tagToSend.setFloat("side_rotation_ratio" + i,
                connectedSidesRatios[i].get().floatValue());
        }
    }

    tagToSend.setByte("valid_sides_byte", validSides);
    return new SPacketUpdateTileEntity(this.getPos(), 0, tagToSend);
}
 
Example 4
Source File: StellarBody.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt) {
	nbt.setInteger("id", this.id);
	nbt.setInteger("temperature", temperature);
	nbt.setString("name", name);
	nbt.setShort("posX", posX);
	nbt.setShort("posZ", posZ);
	nbt.setFloat("size", size);
	nbt.setFloat("seperation", starSeperation);
	
	NBTTagList list = new NBTTagList();
	
	for(StellarBody body : subStars) {
		NBTTagCompound tag = new NBTTagCompound();
		body.writeToNBT(tag);
		list.appendTag(tag);
	}
	
	if(!list.hasNoTags())
		nbt.setTag("subStars", list);
}
 
Example 5
Source File: TileEntityAssemblyPlatform.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag){
    super.writeToNBT(tag);
    tag.setBoolean("clawClosing", shouldClawClose);
    tag.setFloat("clawProgress", clawProgress);
    tag.setFloat("speed", speed);
    tag.setBoolean("drilled", hasDrilledStack);
    tag.setBoolean("lasered", hasLaseredStack);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    tag.setTag("Items", tagList);
}
 
Example 6
Source File: TileEntityPneumaticBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound nbt){
    if(getClass() != TileEntityPneumaticBase.class && saveTeInternals()) {
        super.writeToNBT(nbt);
    }
    nbt.setInteger("currentAir", currentAir);
    nbt.setInteger("volume", volume);
    nbt.setFloat("maxPressure", maxPressure);

    NBTTagCompound tag = new NBTTagCompound();
    nbt.setTag("pneumatic", tag);
    nbt = tag;
    nbt.setInteger("currentAir", currentAir);
    nbt.setInteger("volume", volume);
    nbt.setFloat("maxPressure", maxPressure);
}
 
Example 7
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
 */
public NBTTagCompound save(NBTTagCompound tag, String key, Object value) {
	if (value instanceof Boolean) {
		tag.setBoolean(key + "::nova.isBoolean", true);
		tag.setBoolean(key, (boolean) value);
	} else if (value instanceof Byte) {
		tag.setBoolean(key + "::nova.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 BigInteger) {
		tag.setBoolean(key + "::nova.isBigInteger", true);
		tag.setString(key, ((BigInteger) value).toString());
	} else if (value instanceof BigDecimal) {
		tag.setBoolean(key + "::nova.isBigDecimal", true);
		tag.setString(key, ((BigDecimal) value).toString());
	} 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 8
Source File: GTTileCharcoalPit.java    From GT-Classic 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("active", this.getActive());
	nbt.setFloat("progress", this.progress);
	nbt.setFloat("operation", recipeOperation);
	return nbt;
}
 
Example 9
Source File: MultiblockTurbine.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound data) {
	data.setTag("inputTank", tanks[TANK_INPUT].writeToNBT(new NBTTagCompound()));
	data.setTag("outputTank", tanks[TANK_OUTPUT].writeToNBT(new NBTTagCompound()));
	data.setBoolean("active", active);
	data.setFloat("energy", energyStored);
	data.setInteger("ventStatus", ventStatus.ordinal());
	data.setFloat("rotorEnergy", rotorEnergy);
	data.setInteger("maxIntakeRate", maxIntakeRate);
	data.setBoolean("inductorEngaged", inductorEngaged);
}
 
Example 10
Source File: EntityMoment.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NBTTagCompound serializeNBT() {
	NBTTagCompound compound = new NBTTagCompound();
	if (x != null) compound.setDouble("x", x);
	if (y != null) compound.setDouble("y", y);
	if (z != null) compound.setDouble("z", z);
	if (yaw != null) compound.setFloat("yaw", yaw);
	if (pitch != null) compound.setFloat("pitch", pitch);
	if (health != null) compound.setFloat("health", health);
	if (food != null) compound.setByte("food", food.byteValue());
	if (saturation != null) compound.setFloat("saturation", saturation);
	if (exhaustion != null) compound.setFloat("exhaustion", exhaustion);
	return compound;
}
 
Example 11
Source File: TileEntityLiftLever.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public NBTTagCompound getUpdateTag() {
    NBTTagCompound toReturn = super.getUpdateTag();
    toReturn.setFloat("leverOffset", leverOffset);
    toReturn.setDouble("targetYPosition", targetYPosition);
    return toReturn;
}
 
Example 12
Source File: MetaTileEntityBlockBreaker.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);
    data.setInteger("OutputFacing", getOutputFacing().getIndex());
    data.setInteger("BlockBreakProgress", breakProgressTicksLeft);
    data.setFloat("BlockHardness", currentBlockHardness);
    return data;
}
 
Example 13
Source File: DamageXpHandler.java    From TinkersToolLeveling with MIT License 5 votes vote down vote up
private NBTTagCompound convertItemDamageDataToTag(ItemStack stack, Float damage) {
  NBTTagCompound tag = new NBTTagCompound();

  NBTTagCompound itemTag = stack.writeToNBT(new NBTTagCompound());
  tag.setTag(TAG_ITEM, itemTag.copy());
  tag.setFloat(TAG_DAMAGE, damage);

  return tag;
}
 
Example 14
Source File: TileDrill.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	
	nbt.setFloat("extendAmt", distanceExtended);
	nbt.setBoolean("extended", extended);
	return nbt;
}
 
Example 15
Source File: EntityWitherCat.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public void writeEntityToNBT(NBTTagCompound root) {
  super.writeEntityToNBT(root);
  root.setFloat("scale", getScale());
  root.setByte("growthMode", (byte) getGrowthMode().ordinal());
}
 
Example 16
Source File: Food.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public static void setCooked(ItemStack is, float value)
{
	NBTTagCompound nbt = getProcTag(is);
	nbt.setFloat("Cooked", value);
	setProcTag(is, nbt);
}
 
Example 17
Source File: Entity.java    From TickDynamic with MIT License 4 votes vote down vote up
/**
 * Save the entity to NBT (calls an abstract helper method to write extra data)
 */
public void writeToNBT(NBTTagCompound p_70109_1_)
{
    try
    {
        p_70109_1_.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ}));
        p_70109_1_.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
        p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch}));
        p_70109_1_.setFloat("FallDistance", this.fallDistance);
        p_70109_1_.setShort("Fire", (short)this.fire);
        p_70109_1_.setShort("Air", (short)this.getAir());
        p_70109_1_.setBoolean("OnGround", this.onGround);
        p_70109_1_.setInteger("Dimension", this.dimension);
        p_70109_1_.setBoolean("Invulnerable", this.invulnerable);
        p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal);
        p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
        p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
        if (customEntityData != null)
        {
            p_70109_1_.setTag("ForgeData", customEntityData);
        }

       for (String identifier : this.extendedProperties.keySet())
       {
            try
            {
                IExtendedEntityProperties props = this.extendedProperties.get(identifier);
                props.saveNBTData(p_70109_1_);
            }
            catch (Throwable t)
            {
                FMLLog.severe("Failed to save extended properties for %s.  This is a mod issue.", identifier);
                t.printStackTrace();
            }
        }

       this.writeEntityToNBT(p_70109_1_);

        if (this.ridingEntity != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();

            if (this.ridingEntity.writeMountToNBT(nbttagcompound1))
            {
                p_70109_1_.setTag("Riding", nbttagcompound1);
            }
        }
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Saving entity NBT");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being saved");
        this.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
}
 
Example 18
Source File: TileCrop.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void writeSyncableNBT(NBTTagCompound nbt)
{
	nbt.setInteger("cropType", this.cropType.getID());
	nbt.setFloat("growth", growth);
}
 
Example 19
Source File: TileEntityCreativeCompressor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound nbt){
    super.writeToNBT(nbt);
    nbt.setFloat("setpoint", pressureSetpoint);
}
 
Example 20
Source File: RadiationHelperSimulator.java    From reactor_simulator with MIT License 4 votes vote down vote up
public NBTTagCompound writeToNBT(NBTTagCompound data) {
  data.setFloat("fertility", fertility);
  return data;
}