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

The following examples show how to use net.minecraft.nbt.NBTTagCompound#getInteger() . 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: PackBase.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
protected void readConfigFromNBT(NBTTagCompound tag) {
    if (this.defaults.fuelCapacity != null) {
        this.fuelCapacity = tag.getInteger("FuelCapacity");
    }
    if (this.defaults.fuelUsage != null) {
        this.fuelUsage = tag.getInteger("FuelUsage");
    }
    if (this.defaults.fuelPerTickIn != null) {
        this.fuelPerTickIn = tag.getInteger("FuelPerTickIn");
    }
    if (this.defaults.fuelPerTickOut != null) {
        this.fuelPerTickOut = tag.getInteger("FuelPerTickOut");
    }
    if (this.defaults.armorReduction != null) {
        this.armorReduction = tag.getInteger("ArmorReduction");
    }
}
 
Example 2
Source File: SatelliteBiomeChanger.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	biomeId = nbt.getInteger("biomeId");

	int array[] = nbt.getIntArray("posList");

	toChangeList.clear();
	for(int i = 0; i < array.length; i +=3) {
		toChangeList.add(new HashedBlockPosition(array[i], array[i+1], array[i+2]));
	}

	array = nbt.getIntArray("biomeList");
	discoveredBiomes.clear();
	for(int i = 0; i < array.length; i ++) {
		discoveredBiomes.add((byte) array[i]);
	}
}
 
Example 3
Source File: SellSign.java    From MyTown2 with The Unlicense 5 votes vote down vote up
public SellSign(TileEntitySign te, NBTTagCompound signData) {
    super(SellSignType.instance);
    this.bp = new BlockPos(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj().provider.dimensionId);
    this.owner = MyTownUniverse.instance.getOrMakeResident(UUID.fromString(signData.getString("Owner")));
    this.price = signData.getInteger("Price");
    this.restricted = signData.getBoolean("Restricted");
    this.plot = MyTownUniverse.instance.plots.get(te.getWorldObj().provider.dimensionId, te.xCoord, te.yCoord, te.zCoord);
}
 
Example 4
Source File: BasicForceNodeTileEntity.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound compound) {
    maxThrust = compound.getDouble("maxThrust");
    currentThrust = compound.getDouble("currentThrust");
    normalVelocityUnoriented = ValkyrienNBTUtils
        .readVectorFromNBT("normalVelocityUnoriented", compound);
    ticksSinceLastControlSignal = compound.getInteger("ticksSinceLastControlSignal");
    super.readFromNBT(compound);
}
 
Example 5
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readCustomNBT(NBTTagCompound compound) {
    super.readCustomNBT(compound);

    NBTTagCompound tag = compound.getCompoundTag("Gadomancy");
    this.multiblockStructurePresent = tag.getBoolean("mBlockPresent");
    this.isMultiblock = tag.getBoolean("mBlockState");
    this.isWorking = tag.getBoolean("manipulating");
    this.workTick = tag.getInteger("workTick");
    if(tag.hasKey("multiblockType")) {
        this.multiblockType = MultiblockType.values()[tag.getInteger("multiblockType")];
    }
    workAspectList.readFromNBT(tag, "workAspectList");
}
 
Example 6
Source File: GTTileDrum.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	this.tank.readFromNBT(nbt.getCompoundTag(NBT_TANK));
	if (nbt.hasKey(NBT_COLOR)) {
		this.color = nbt.getInteger(NBT_COLOR);
	} else {
		this.color = 16383998;
	}
	this.flow = nbt.getBoolean(NBT_FLOW);
}
 
Example 7
Source File: MoCItemAmulet.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt)
{
   	this.creatureType = nbt.getInteger("CreatureType");
    this.health = nbt.getInteger("Health");
    this.edad = nbt.getInteger("Edad");
    this.name = nbt.getString("Name");
    this.spawnClass = nbt.getInteger("SpawnClass");
    this.rideable = nbt.getBoolean("Rideable");
    this.armor = nbt.getByte("Armor");
    this.adult = nbt.getBoolean("Adult");
    this.ownerName = nbt.getString("OwnerName");
}
 
Example 8
Source File: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void deserializeNBT(NBTTagCompound compound) {
    super.deserializeNBT(compound);
    this.ventingSide = EnumFacing.VALUES[compound.getInteger("VentingSide")];
    this.needsVenting = compound.getBoolean("NeedsVenting");
    this.ventingStuck = compound.getBoolean("VentingStuck");
}
 
Example 9
Source File: TargetData.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NBTTagCompound readTargetTagFromNBT(NBTTagCompound nbt)
{
    if (nbtHasTargetTag(nbt) == false)
    {
        return null;
    }

    NBTTagCompound tag = nbt.getCompoundTag("Target");
    this.pos = new BlockPos(tag.getInteger("posX"), tag.getInteger("posY"), tag.getInteger("posZ"));
    this.dimension = tag.getInteger("Dim");
    this.dimensionName = tag.getString("DimName");
    this.blockName = tag.getString("BlockName");
    this.blockMeta = tag.getByte("BlockMeta");
    this.itemMeta = tag.getByte("ItemMeta");
    this.blockFace = tag.getByte("BlockFace");
    this.facing = EnumFacing.byIndex(this.blockFace);

    this.dPosX = tag.hasKey("dPosX", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosX") : this.pos.getX() + 0.5d;
    this.dPosY = tag.hasKey("dPosY", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosY") : this.pos.getY();
    this.dPosZ = tag.hasKey("dPosZ", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosZ") : this.pos.getZ() + 0.5d;

    if (tag.hasKey("Yaw", Constants.NBT.TAG_FLOAT) && tag.hasKey("Pitch", Constants.NBT.TAG_FLOAT))
    {
        this.hasRotation = true;
        this.yaw = tag.getFloat("Yaw");
        this.pitch = tag.getFloat("Pitch");
    }

    return tag;
}
 
Example 10
Source File: EntityZundaArrow.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound) {
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Duration")) {
        this.duration = compound.getInteger("Duration");
    }
}
 
Example 11
Source File: TileKnowledgeBook.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readCustomNBT(NBTTagCompound compound) {
    this.ticksCognitio = compound.getInteger("cognitio");
    this.workResearchAspects = NBTHelper.getAspectList(compound, "workAspects");
    this.researching = compound.getBoolean("researching");
    this.storedResearchNote = NBTHelper.getStack(compound, "crystalStack");
}
 
Example 12
Source File: CellSavedWorldData.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
 	storageIndex = nbt.getInteger("index");
	for (String s : nbt.getKeySet()) {
		Integer[] temp = new Integer[6];
		for (int i = 0; i < nbt.getIntArray(s).length; i++)
			temp[i] = nbt.getIntArray(s)[i];
		storageCells.put(s, temp);
	}
}
 
Example 13
Source File: GTColorItemBlock.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Color getColor(ItemStack stack, int index) {
	NBTTagCompound nbt = StackUtil.getNbtData(stack);
	if (nbt.hasKey("color")) {
		return new Color(nbt.getInteger("color"));
	}
	if (this.block instanceof IGTColorBlock) {
		return ((IGTColorBlock) block).getColor(null, null, null, this.block, index);
	} else {
		return null;
	}
}
 
Example 14
Source File: TileEntityAirCannon.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);
    redstonePowered = tag.getBoolean("redstonePowered");
    targetRotationAngle = tag.getFloat("targetRotationAngle");
    targetHeightAngle = tag.getFloat("targetHeightAngle");
    rotationAngle = tag.getFloat("rotationAngle");
    heightAngle = tag.getFloat("heightAngle");
    gpsX = tag.getInteger("gpsX");
    gpsY = tag.getInteger("gpsY");
    gpsZ = tag.getInteger("gpsZ");
    if(tag.hasKey("fireOnRightAngle")) {
        redstoneMode = tag.getBoolean("fireOnRightAngle") ? 0 : 1; //TODO remove legacy
    } else {
        redstoneMode = tag.getByte("redstoneMode");
    }

    coordWithinReach = tag.getBoolean("targetWithinReach");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for(int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if(slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }

    trackedItemIds = new HashSet<UUID>();
    tagList = tag.getTagList("trackedItems", 10);
    for(int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound t = tagList.getCompoundTagAt(i);
        trackedItemIds.add(new UUID(t.getLong("UUIDMost"), t.getLong("UUIDLeast")));
    }

    if(tag.hasKey("inventoryX")) {
        lastInsertingInventory = new ChunkPosition(tag.getInteger("inventoryX"), tag.getInteger("inventoryY"), tag.getInteger("inventoryZ"));
        lastInsertingInventorySide = ForgeDirection.getOrientation(tag.getByte("inventorySide"));
    } else {
        lastInsertingInventory = null;
        lastInsertingInventorySide = null;
    }
}
 
Example 15
Source File: NBTUtil.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public static int getInteger(NBTTagCompound compound, String key, int ifnone) {
    if (compound == null) return ifnone;
    return compound.hasKey(key) ? compound.getInteger(key) : ifnone;
}
 
Example 16
Source File: Structure.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
public void readNBT(NBTTagCompound c) {
	chunkX = c.getInteger("chunkX");
	chunkZ = c.getInteger("chunkZ");
	type = c.getString("type");
}
 
Example 17
Source File: TileEntityReservoirBase.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    priority = compound.getInteger(TAG_PRIOR);
}
 
Example 18
Source File: LifeEssenceNetwork.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbttagcompound)
{
    currentEssence = nbttagcompound.getInteger("currentEssence");
}
 
Example 19
Source File: SubTileEntity.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
public final void readFromPacketNBTInternal(NBTTagCompound cmp) {
	if(cmp.hasKey(TAG_TICKS_EXISTED))
		ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED);
	readFromPacketNBT(cmp);
}
 
Example 20
Source File: EntanglementRegistry.java    From qcraft-mod with Apache License 2.0 4 votes vote down vote up
public void readFromNBT( NBTTagCompound nbt )
{
    m_nextUnusedFrequency = nbt.getInteger( "nextUnusedFrequency" );
}