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

The following examples show how to use net.minecraft.nbt.NBTTagCompound#getByte() . 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: TileEntityNewBrewingStand.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	NBTTagList nbttaglist = nbt.getTagList("Items", 10);
	inventory = new ItemStack[getSizeInventory()];

	for (int i = 0; i < nbttaglist.tagCount(); i++) {
		NBTTagCompound nbt1 = nbttaglist.getCompoundTagAt(i);
		byte b0 = nbt1.getByte("Slot");

		if (b0 >= 0 && b0 < inventory.length)
			inventory[b0] = ItemStack.loadItemStackFromNBT(nbt1);
	}

	brewTime = nbt.getShort("BrewTime");

	if (nbt.hasKey("Fuel", Constants.NBT.TAG_SHORT)) {
		fuel = nbt.getShort("Fuel");
		if (fuel > 0)
			currentFuel = 30;
	} else {
		fuel = nbt.getInteger("Fuel");
		currentFuel = nbt.getInteger("CurrentFuel");
	}
}
 
Example 2
Source File: TileEntityUniversalSensor.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    setSensorSetting(tag.getString("sensorSetting"));
    invertedRedstone = tag.getBoolean("invertedRedstone");
    dishSpeed = tag.getFloat("dishSpeed");
    sensorGuiText = tag.getString("sensorText");
    // 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);
        }
    }
    positions = getGPSPositionsStatic(this, getRange());
}
 
Example 3
Source File: TileEntityAssemblyPlatform.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    shouldClawClose = tag.getBoolean("clawClosing");
    clawProgress = tag.getFloat("clawProgress");
    speed = tag.getFloat("speed");
    hasDrilledStack = tag.getBoolean("drilled");
    hasLaseredStack = tag.getBoolean("lasered");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[1];
    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);
        }
    }
}
 
Example 4
Source File: TileGravityController.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void useNetworkData(EntityPlayer player, Side side, byte id,
		NBTTagCompound nbt) {
	super.useNetworkData(player, side, id, nbt);

	if(id == 3) {
		setProgress(0, nbt.getShort("progress"));
		setProgress(1, nbt.getShort("radius"));
	}
	else if(id == 4) {
		byte bytes[] = nbt.getByteArray("bytes");
		for(int i = 0; i < 6; i++)
			sideSelectorModule.setStateForSide(i, bytes[i]);
	}
	else if(id == 5) {
		state = RedstoneState.values()[nbt.getByte("redstoneState")];
		redstoneControl.setRedstoneState(state);
	}
}
 
Example 5
Source File: TileEntityOmnidirectionalHopper.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    inputDir = ForgeDirection.getOrientation(tag.getInteger("inputDir"));
    redstoneMode = tag.getInteger("redstoneMode");
    leaveMaterial = tag.getBoolean("leaveMaterial");

    NBTTagList tagList = tag.getTagList("Inventory", 10);
    inventory = new ItemStack[inventory.length];
    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);
        }
    }
}
 
Example 6
Source File: NetworkSerializer.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
private NetworkObject<MCPos> loadFromTag(NBTTagCompound tag){
    EnumNetworkObject type = EnumNetworkObject.VALUES[tag.getByte("id")];
    switch(type){
        case RAIL:
            return MCNetworkRail.fromTag(tag);
        case SIGNAL:
            return MCNetworkSignal.fromTag(tag);
        case REMOVAL_MARKER:
            return NetworkRemovalMarker.fromTag(tag);
        case RAIL_LINK:
            return MCNetworkRailLink.fromTag(tag);
        case STATION:
            return MCNetworkStation.fromTag(tag);
        case TELEPORT_RAIL:
            return MCNetworkTeleportRail.fromTag(tag);
        default:
            throw new IllegalStateException("Unsupported type: " + type);
    }
}
 
Example 7
Source File: TileEntityInventory.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag) {
	super.readFromNBT(tag);
	
	// Inventories
	_inventories = new ItemStack[getSizeInventory()];
	if(tag.hasKey("Items")) {
		NBTTagList tagList = tag.getTagList("Items", 10);
		for(int i = 0; i < tagList.tagCount(); i++) {
			NBTTagCompound itemTag = (NBTTagCompound)tagList.getCompoundTagAt(i);
			int slot = itemTag.getByte("Slot") & 0xff;
			if(slot >= 0 && slot <= _inventories.length) {
				ItemStack itemStack = new ItemStack((Block)null,0,0);
				itemStack.readFromNBT(itemTag);
				_inventories[slot] = itemStack;
			}
		}
	}
}
 
Example 8
Source File: TileEntityBloomeryFurnace.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public void readFromNBT (NBTTagCompound tag) {
    super.readFromNBT(tag);

    NBTTagList list = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    furnaceItemStacks = new ItemStack[getSizeInventory()];

    for (int i = 0, n = list.tagCount(); i < n; i++) {
        NBTTagCompound itemTag = list.getCompoundTagAt(i);
        byte slot = itemTag.getByte("Slot");

        if (slot >= 0 && slot < furnaceItemStacks.length)
            furnaceItemStacks[slot] = ItemStack.loadItemStackFromNBT(itemTag);
    }

    furnaceBurnTime = tag.getShort("BurnTime");
    furnaceCookTime = tag.getShort("CookTime");
    currentItemBurnTime = getItemBurnTime(furnaceItemStacks[SLOT_FUEL]);

    if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
        customName = tag.getString("CustomName");
}
 
Example 9
Source File: UtilItemModular.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Returns the position of the ItemStack in the NBTTagList that is stored in the slot slotNum
 * in whatever container handles it.
 * @param tagList
 * @param slotNum
 * @return the position of the stack in slot slotNum in the list, or -1 if it doesn't exist in the list
 */
public static int getListPositionOfStackInSlot(NBTTagList nbtTagList, int slotNum)
{
    int size = nbtTagList.tagCount();

    for (int i = 0; i < size; i++)
    {
        NBTTagCompound tag = nbtTagList.getCompoundTagAt(i);

        if (tag.hasKey("Slot", Constants.NBT.TAG_BYTE) && tag.getByte("Slot") == slotNum)
        {
            return i;
        }
    }

    return -1;
}
 
Example 10
Source File: TileEntityAssemblyIOUnit.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    clawProgress = tag.getFloat("clawProgress");
    shouldClawClose = tag.getBoolean("clawClosing");
    state = tag.getByte("state");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[1];
    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);
        }
    }
}
 
Example 11
Source File: TileEntityFluxCompressor.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    energy.readFromNBT(tag);
    readInventoryFromNBT(tag, inventory);
    redstoneMode = tag.getByte("redstoneMode");
}
 
Example 12
Source File: SignalsUtils.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static void readInventoryFromNBT(NBTTagCompound tag, ItemStack[] stacks, String tagName){
    for(int i = 0; i < stacks.length; i++) {
        stacks[i] = null;
    }
    NBTTagList tagList = tag.getTagList(tagName, 10);
    for(int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound itemTag = tagList.getCompoundTagAt(i);
        int slot = itemTag.getByte("Slot");
        if(slot >= 0 && slot < stacks.length) {
            stacks[slot] = new ItemStack(itemTag);
        }
    }
}
 
Example 13
Source File: TileEntityFuelingStation.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	state = RedstoneState.values()[nbt.getByte("redstoneState")];
	redstoneControl.setRedstoneState(state);

	if(nbt.hasKey("masterPos")) {
		int[] pos = nbt.getIntArray("masterPos");
		setMasterBlock(new BlockPos(pos[0], pos[1], pos[2]));
	}
}
 
Example 14
Source File: ECPrivateInventory.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void readFromNBT(NBTTagList nbtList)
{
	for (int i = 0; i < nbtList.tagCount(); ++i)
	{
		NBTTagCompound nbttagcompound = (NBTTagCompound) nbtList.tagAt(i);
		int j = nbttagcompound.getByte("Slot") & 255;

		if (j >= 0 && j < slots.size())
		{
			slots.set(j, ItemStack.loadItemStackFromNBT(nbttagcompound));
		}
	}
}
 
Example 15
Source File: TileEntityCandelabra.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void readFromNBT (NBTTagCompound tag) {
    super.readFromNBT(tag);

    direction = 0;
    if (tag.hasKey("Dir"))
        direction = tag.getByte("Dir");

    level = tag.getByte("Lev");
}
 
Example 16
Source File: EntityLaser.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	this.xTile = par1NBTTagCompound.getShort("xTile");
	this.yTile = par1NBTTagCompound.getShort("yTile");
	this.zTile = par1NBTTagCompound.getShort("zTile");
	this.inTile = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
	this.inData = par1NBTTagCompound.getByte("inData") & 255;
	this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
}
 
Example 17
Source File: GT_TileEntity_MegaBlastFurnace.java    From bartworks with MIT License 5 votes vote down vote up
@Override
public void loadNBTData(NBTTagCompound aNBT) {
    super.loadNBTData(aNBT);
    this.circuitMode = aNBT.getByte("circuitMode");
    this.glasTier = aNBT.getByte("glasTier");
    this.lEUt = aNBT.getLong("lEUt");
}
 
Example 18
Source File: TileGuidanceComputerHatch.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	chipEjected = nbt.getBoolean("chipEjected");
	state = RedstoneState.values()[nbt.getByte("redstoneState")];

	short status = nbt.getShort("statuses");
	for(int i = 0; i < buttonState.length; i++) {
		buttonState[i] = (status & 1<<i) != 0; 
	}

	super.readFromNBT(nbt);
}
 
Example 19
Source File: TileEntityRefinery.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    oilTank.readFromNBT(tag.getCompoundTag("oilTank"));
    outputTank.readFromNBT(tag.getCompoundTag("outputTank"));
    redstoneMode = tag.getByte("redstoneMode");
}
 
Example 20
Source File: SyncableFlags.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag, String name) {
	value = tag.getByte(name);
}