use of net.minecraftforge.common.IExtendedEntityProperties in project PneumaticCraft by MineMaarten.
the class TileEntityProgrammableController method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
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);
NBTTagCompound tankTag = new NBTTagCompound();
tank.writeToNBT(tankTag);
tag.setTag("tank", tankTag);
NBTTagList droneItems = new NBTTagList();
for (int currentIndex = 0; currentIndex < getDroneSlots(); ++currentIndex) {
if (getFakePlayer().inventory.getStackInSlot(currentIndex) != null) {
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte) currentIndex);
getFakePlayer().inventory.getStackInSlot(currentIndex).writeToNBT(tagCompound);
droneItems.appendTag(tagCompound);
}
}
tag.setTag("droneItems", droneItems);
NBTTagList extendedList = new NBTTagList();
for (Map.Entry<String, IExtendedEntityProperties> entry : properties.entrySet()) {
NBTTagCompound propertyTag = new NBTTagCompound();
propertyTag.setString("key", entry.getKey());
entry.getValue().saveNBTData(propertyTag);
extendedList.appendTag(propertyTag);
}
tag.setTag("extendedProperties", extendedList);
}
use of net.minecraftforge.common.IExtendedEntityProperties in project PneumaticCraft by MineMaarten.
the class TileEntityProgrammableController method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
NBTTagList tagList = tag.getTagList("Items", 10);
inventory = new ItemStack[INVENTORY_SIZE];
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);
}
}
tank.readFromNBT(tag.getCompoundTag("tank"));
NBTTagList droneItemTag = tag.getTagList("droneItems", 10);
droneItems = new ItemStack[getDroneSlots()];
for (int i = 0; i < droneItemTag.tagCount(); ++i) {
NBTTagCompound tagCompound = droneItemTag.getCompoundTagAt(i);
byte slot = tagCompound.getByte("Slot");
if (slot >= 0 && slot < droneItems.length) {
droneItems[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
NBTTagList extendedList = tag.getTagList("extendedProperties", 10);
for (int i = 0; i < extendedList.tagCount(); ++i) {
NBTTagCompound propertyTag = extendedList.getCompoundTagAt(i);
String key = propertyTag.getString("key");
IExtendedEntityProperties property = properties.get(key);
if (property != null) {
property.loadNBTData(propertyTag);
} else {
Log.warning("Extended entity property \"" + key + "\" doesn't exist in a Programmable Controller");
}
}
}
Aggregations