use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class CoreRoutedPipe method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
synchronized (routerIdLock) {
if (routerId == null || routerId.isEmpty()) {
if (router != null) {
routerId = router.getId().toString();
} else {
routerId = UUID.randomUUID().toString();
}
}
}
nbttagcompound.setString("routerId", routerId);
nbttagcompound.setLong("stat_lifetime_sent", stat_lifetime_sent);
nbttagcompound.setLong("stat_lifetime_recieved", stat_lifetime_recieved);
nbttagcompound.setLong("stat_lifetime_relayed", stat_lifetime_relayed);
if (getLogisticsModule() != null) {
getLogisticsModule().writeToNBT(nbttagcompound);
}
NBTTagCompound upgradeNBT = new NBTTagCompound();
upgradeManager.writeToNBT(upgradeNBT);
nbttagcompound.setTag("upgradeManager", upgradeNBT);
NBTTagCompound powerNBT = new NBTTagCompound();
powerHandler.writeToNBT(powerNBT);
if (!powerNBT.hasNoTags()) {
nbttagcompound.setTag("powerHandler", powerNBT);
}
NBTTagList sendqueue = new NBTTagList();
for (Triplet<IRoutedItem, ForgeDirection, ItemSendMode> p : _sendQueue) {
NBTTagCompound tagentry = new NBTTagCompound();
NBTTagCompound tagentityitem = new NBTTagCompound();
p.getValue1().writeToNBT(tagentityitem);
tagentry.setTag("entityitem", tagentityitem);
tagentry.setByte("from", (byte) (p.getValue2().ordinal()));
tagentry.setByte("mode", (byte) (p.getValue3().ordinal()));
sendqueue.appendTag(tagentry);
}
nbttagcompound.setTag("sendqueue", sendqueue);
for (int i = 0; i < 6; i++) {
if (signItem[i] != null) {
nbttagcompound.setBoolean("PipeSign_" + i, true);
int signType = -1;
List<Class<? extends IPipeSign>> typeClasses = ItemPipeSignCreator.signTypes;
for (int j = 0; j < typeClasses.size(); j++) {
if (typeClasses.get(j) == signItem[i].getClass()) {
signType = j;
break;
}
}
nbttagcompound.setInteger("PipeSign_" + i + "_type", signType);
NBTTagCompound tag = new NBTTagCompound();
signItem[i].writeToNBT(tag);
nbttagcompound.setTag("PipeSign_" + i + "_tags", tag);
} else {
nbttagcompound.setBoolean("PipeSign_" + i, false);
}
}
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class LogisticsTileGenericSubMultiBlock method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagList nbtList = new NBTTagList();
for (DoubleCoordinates pos : mainPipePos) {
NBTTagCompound compound = new NBTTagCompound();
pos.writeToNBT("MainPipePos_", compound);
nbtList.appendTag(compound);
}
nbt.setTag("MainPipePosList", nbtList);
NBTTagList nbtTypeList = new NBTTagList();
for (CoreMultiBlockPipe.SubBlockTypeForShare type : subTypes) {
if (type == null)
continue;
nbtTypeList.appendTag(new NBTTagString(type.name()));
}
nbt.setTag("SubTypeList", nbtTypeList);
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class ItemIdentifierInventory method readFromNBT.
public void readFromNBT(NBTTagCompound nbttagcompound, String prefix) {
NBTTagList nbttaglist = nbttagcompound.getTagList(prefix + "items", nbttagcompound.getId());
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j);
int index = nbttagcompound2.getInteger("index");
if (index < _contents.length) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbttagcompound2);
if (stack != null) {
ItemIdentifierStack itemstack = ItemIdentifierStack.getFromStack(stack);
if (isValidStack(itemstack)) {
_contents[index] = itemstack;
}
}
} else {
LogisticsPipes.log.fatal("SimpleInventory: java.lang.ArrayIndexOutOfBoundsException: " + index + " of " + _contents.length);
}
}
updateContents();
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class SimpleStackInventory method readFromNBT.
public void readFromNBT(NBTTagCompound nbttagcompound, String prefix) {
NBTTagList nbttaglist = nbttagcompound.getTagList(prefix + "items", nbttagcompound.getId());
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j);
int index = nbttagcompound2.getInteger("index");
if (index < _contents.length) {
_contents[index] = ItemStack.loadItemStackFromNBT(nbttagcompound2);
} else {
LogisticsPipes.log.fatal("SimpleInventory: java.lang.ArrayIndexOutOfBoundsException: " + index + " of " + _contents.length);
}
}
}
use of net.minecraft.nbt.NBTTagList in project SimplyJetpacks by Tonius.
the class ItemMysteriousPotato method onItemUse.
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int meta, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityMobSpawner) {
NBTTagCompound tag = new NBTTagCompound();
tile.writeToNBT(tag);
tag.setString("EntityId", "Zombie");
NBTTagList spawnPotentials = new NBTTagList();
NBTTagCompound zombieSpawn = new NBTTagCompound();
zombieSpawn.setString("Type", "Zombie");
zombieSpawn.setInteger("Weight", 1);
NBTTagCompound zombieSpawnProperties = new NBTTagCompound();
zombieSpawnProperties.setString("id", "Zombie");
NBTTagList equipment = new NBTTagList();
equipment.appendTag(new NBTTagCompound());
equipment.appendTag(new NBTTagCompound());
equipment.appendTag(new NBTTagCompound());
equipment.appendTag(ModItems.jetpackPotato.writeToNBT(new NBTTagCompound()));
zombieSpawnProperties.setTag("Equipment", equipment);
NBTTagList dropChances = new NBTTagList();
for (int i = 0; i <= 4; i++) {
dropChances.appendTag(new NBTTagFloat(0.0F));
}
zombieSpawnProperties.setTag("DropChances", dropChances);
zombieSpawn.setTag("Properties", zombieSpawnProperties);
spawnPotentials.appendTag(zombieSpawn);
tag.setTag("SpawnPotentials", spawnPotentials);
tag.setShort("SpawnCount", (short) 2);
tag.setShort("SpawnRange", (short) 8);
tag.setShort("Delay", (short) -1);
tag.setShort("MinSpawnDelay", (short) 30);
tag.setShort("MaxSpawnDelay", (short) 60);
tag.setShort("MaxNearbyEntities", (short) 10);
tag.setShort("RequiredPlayerRange", (short) 96);
tile.readFromNBT(tag);
}
}
return true;
}
Aggregations