use of buildcraft.api.blueprints.MappingNotFoundException in project BuildCraft by BuildCraft.
the class Blueprint method loadContents.
@Override
public void loadContents(NBTTagCompound nbt) throws BptError {
mapping.read(nbt.getCompoundTag("idMapping"));
NBTBase base = nbt.getTag("contents");
if (base instanceof NBTTagCompound) {
NBTTagCompound contents = (NBTTagCompound) base;
for (BlockPos pos : BlockPos.getAllInBox(BlockPos.ORIGIN, size.subtract(Utils.POS_ONE))) {
NBTTagCompound single = contents.getCompoundTag(StringUtilBC.blockPosToShortString(pos));
loadSingleSchematicFromNBT(pos, single);
}
} else {
// 1.7.10 back-compat
NBTTagList nbtContents = nbt.getTagList("contents", Constants.NBT.TAG_COMPOUND);
int index = 0;
for (int x = 0; x < size.getX(); ++x) {
for (int y = 0; y < size.getY(); ++y) {
for (int z = 0; z < size.getZ(); ++z) {
NBTTagCompound cpt = nbtContents.getCompoundTagAt(index);
loadSingleSchematicFromNBT(new BlockPos(x, y, z), cpt);
index++;
}
}
}
}
NBTTagList entitiesNBT = nbt.getTagList("entities", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < entitiesNBT.tagCount(); ++i) {
NBTTagCompound cpt = entitiesNBT.getCompoundTagAt(i);
if (cpt.hasKey("entityId")) {
Class<? extends Entity> entity;
try {
entity = mapping.getEntityForId(cpt.getInteger("entityId"));
} catch (MappingNotFoundException e) {
entity = null;
isComplete = false;
}
if (entity != null) {
SchematicEntity s = SchematicRegistry.INSTANCE.createSchematicEntity(entity);
s.readSchematicFromNBT(cpt, mapping);
s.idsToWorld(mapping);
entities.add(s);
} else {
isComplete = false;
}
}
}
}
use of buildcraft.api.blueprints.MappingNotFoundException 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.MappingNotFoundException in project BuildCraft by BuildCraft.
the class SchematicPipe method idsToWorld.
@Override
public void idsToWorld(MappingRegistry registry) {
super.idsToWorld(registry);
if (tileNBT.hasKey("pipeId")) {
try {
Item item = registry.getItemForId(tileNBT.getInteger("pipeId"));
tileNBT.setString("pipeId", Item.itemRegistry.getNameForObject(item).toString());
} catch (MappingNotFoundException e) {
tileNBT.removeTag("pipeId");
}
}
}
use of buildcraft.api.blueprints.MappingNotFoundException in project BuildCraft by BuildCraft.
the class Blueprint method loadSingleSchematicFromNBT.
private void loadSingleSchematicFromNBT(BlockPos pos, NBTTagCompound cpt) {
if (cpt.hasKey("blockId")) {
Block block;
try {
block = mapping.getBlockForId(cpt.getInteger("blockId"));
} catch (MappingNotFoundException e) {
block = null;
isComplete = false;
}
if (block != null) {
int meta = cpt.getInteger("blockMeta");
SchematicBlockBase schematic = SchematicRegistry.INSTANCE.createSchematicBlock(block.getStateFromMeta(meta));
if (schematic != null) {
schematic.readSchematicFromNBT(cpt, mapping);
if (!schematic.doNotUse()) {
schematic.idsToWorld(mapping);
switch(schematic.getBuildingPermission()) {
case ALL:
break;
case CREATIVE_ONLY:
if (buildingPermission == BuildingPermission.ALL) {
buildingPermission = BuildingPermission.CREATIVE_ONLY;
}
break;
case NONE:
buildingPermission = BuildingPermission.NONE;
break;
}
} else {
schematic = null;
isComplete = false;
}
}
set(pos, schematic);
} else {
set(pos, null);
isComplete = false;
}
} else {
set(pos, null);
}
}
Aggregations