use of net.minecraft.nbt.NBTTagList in project Minechem by iopleke.
the class JournalItem method getAuthors.
/**
* Gets a list of authors
*
* @param itemStack the journal Stack
* @return an array of authors can be empty
*/
public String[] getAuthors(ItemStack itemStack) {
if (itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey("authors")) {
NBTTagList authorsTag = itemStack.stackTagCompound.getTagList("authors", 8);
String[] authors = new String[authorsTag.tagCount()];
for (int i = 0; i < authorsTag.tagCount(); i++) {
authors[i] = authorsTag.getStringTagAt(i);
}
return ArrayHelper.removeNulls(authors, String.class);
}
return new String[0];
}
use of net.minecraft.nbt.NBTTagList in project Minechem by iopleke.
the class JournalItem method getKnowledgeKeys.
/**
* Gets a list of knowledgeKeys
*
* @param itemStack the journal Stack
* @return an array of knowledgeKeys can be empty
*/
public String[] getKnowledgeKeys(ItemStack itemStack) {
if (itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey("research")) {
NBTTagList authorsTag = itemStack.stackTagCompound.getTagList("research", 8);
String[] knowledgeKeys = new String[authorsTag.tagCount()];
for (int i = 0; i < authorsTag.tagCount(); i++) {
knowledgeKeys[i] = authorsTag.getStringTagAt(i);
}
return ArrayHelper.removeNulls(knowledgeKeys, String.class);
}
return new String[0];
}
use of net.minecraft.nbt.NBTTagList in project Minechem by iopleke.
the class BasicInventoryTileEntity method readFromNBT.
/**
* Read saved values from NBT
*
* @param nbttagcompound
*/
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.getTagList(inventory.getInventoryName(), Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < inventory.getInventory().length; i++) {
inventory.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i)));
}
}
use of net.minecraft.nbt.NBTTagList in project Minechem by iopleke.
the class BasicInventoryTileEntity method writeToNBT.
/**
* Save data to NBT
*
* @param nbttagcompound
*/
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList();
for (ItemStack stack : inventory.getInventory()) {
if (stack != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
stack.writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
} else {
nbttaglist.appendTag(new NBTTagCompound());
}
}
nbttagcompound.setTag(inventory.getInventoryName(), nbttaglist);
}
use of net.minecraft.nbt.NBTTagList in project MineFactoryReloaded by powercrystals.
the class TileEntityRedNetLogic method readCircuitsOnly.
public void readCircuitsOnly(NBTTagCompound nbttagcompound) {
NBTTagList circuits = nbttagcompound.getTagList("circuits");
if (circuits != null) {
for (int c = 0; c < circuits.tagCount(); c++) {
initCircuit(c, ((NBTTagCompound) circuits.tagAt(c)).getString("circuit"));
NBTTagList inputPins = ((NBTTagCompound) circuits.tagAt(c)).getTagList("inputPins");
if (inputPins != null) {
for (int i = 0; i < inputPins.tagCount() && i < _pinMappingInputs[c].length; i++) {
int pin = ((NBTTagCompound) inputPins.tagAt(i)).getInteger("pin");
int buffer = ((NBTTagCompound) inputPins.tagAt(i)).getInteger("buffer");
_pinMappingInputs[c][i] = new PinMapping(pin, buffer);
}
}
NBTTagList outputPins = ((NBTTagCompound) circuits.tagAt(c)).getTagList("outputPins");
if (outputPins != null) {
for (int i = 0; i < outputPins.tagCount() && i < _pinMappingOutputs[c].length; i++) {
int pin = ((NBTTagCompound) outputPins.tagAt(i)).getInteger("pin");
int buffer = ((NBTTagCompound) outputPins.tagAt(i)).getInteger("buffer");
_pinMappingOutputs[c][i] = new PinMapping(pin, buffer);
}
}
NBTTagCompound circuitState = ((NBTTagCompound) circuits.tagAt(c)).getCompoundTag("state");
if (circuitState != null) {
_circuits[c].readFromNBT(circuitState);
}
}
}
}
Aggregations