use of buildcraft.api.blueprints.MappingRegistry in project BuildCraft by BuildCraft.
the class Sequence method writeToNBT.
public void writeToNBT(NBTTagCompound nbt) {
nbt.setLong("initialDate", initialDate);
MappingRegistry registry = new MappingRegistry();
NBTTagList list = new NBTTagList();
for (SequenceAction action : actions) {
NBTTagCompound cpt = new NBTTagCompound();
action.writeToNBT(cpt);
cpt.setString("class", classToStr.get(action.getClass()));
registry.scanAndTranslateStacksToRegistry(cpt);
list.appendTag(cpt);
}
nbt.setTag("actions", list);
NBTTagCompound registryNBT = new NBTTagCompound();
registry.write(registryNBT);
nbt.setTag("registry", registryNBT);
}
use of buildcraft.api.blueprints.MappingRegistry in project BuildCraft by BuildCraft.
the class Sequence method readFromNBT.
public void readFromNBT(NBTTagCompound nbt) {
initialDate = nbt.getLong("initialDate");
MappingRegistry registry = new MappingRegistry();
registry.read(nbt.getCompoundTag("registry"));
NBTTagList list = nbt.getTagList("actions", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound cpt = list.getCompoundTagAt(i);
try {
registry.scanAndTranslateStacksToWorld(cpt);
SequenceAction action = (SequenceAction) strToClass.get(cpt.getString("class")).newInstance();
action.world = world;
action.readFromNBT(cpt);
action.date = (action.date - initialDate) + world.getTotalWorldTime();
actions.add(action);
} catch (MappingNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of buildcraft.api.blueprints.MappingRegistry in project BuildCraft by BuildCraft.
the class BuildingItem method readFromNBT.
public void readFromNBT(NBTTagCompound nbt) throws MappingNotFoundException {
origin = NBTUtilBC.readVec3d(nbt, "origin");
destination = NBTUtilBC.readVec3d(nbt, "destination");
lifetime = nbt.getFloat("lifetime");
NBTTagList items = nbt.getTagList("items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); ++i) {
StackAtPosition sPos = new StackAtPosition();
sPos.stack = ItemStack.loadItemStackFromNBT(items.getCompoundTagAt(i));
stacksToDisplay.add(sPos);
}
MappingRegistry registry = new MappingRegistry();
registry.read(nbt.getCompoundTag("registry"));
if (nbt.getByte("slotKind") == 0) {
slotToBuild = new BuildingSlotBlock();
} else {
slotToBuild = new BuildingSlotEntity();
}
slotToBuild.readFromNBT(nbt.getCompoundTag("slotToBuild"), registry);
}
use of buildcraft.api.blueprints.MappingRegistry in project BuildCraft by BuildCraft.
the class BuildingItem method writeToNBT.
public void writeToNBT(NBTTagCompound nbt) {
nbt.setTag("origin", NBTUtilBC.writeVec3d(origin));
nbt.setTag("destination", NBTUtilBC.writeVec3d(destination));
nbt.setFloat("lifetime", lifetime);
NBTTagList items = new NBTTagList();
for (StackAtPosition s : stacksToDisplay) {
NBTTagCompound cpt = new NBTTagCompound();
s.stack.writeToNBT(cpt);
items.appendTag(cpt);
}
nbt.setTag("items", items);
MappingRegistry registry = new MappingRegistry();
NBTTagCompound slotNBT = new NBTTagCompound();
NBTTagCompound registryNBT = new NBTTagCompound();
slotToBuild.writeToNBT(slotNBT, registry);
registry.write(registryNBT);
nbt.setTag("registry", registryNBT);
if (slotToBuild instanceof BuildingSlotBlock) {
nbt.setByte("slotKind", (byte) 0);
} else {
nbt.setByte("slotKind", (byte) 1);
}
nbt.setTag("slotToBuild", slotNBT);
}
Aggregations