use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.
the class TilePipeHolder method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
if (nbt.hasKey("pipe")) {
try {
pipe = new Pipe(this, nbt.getCompoundTag("pipe"));
eventBus.registerHandler(pipe.behaviour);
eventBus.registerHandler(pipe.flow);
if (pipe.flow instanceof IFlowItems) {
eventBus.registerHandler(FilterEventHandler.class);
}
} catch (InvalidInputDataException e) {
// Unfortunately we can't throw an exception because then this tile won't persist :/
e.printStackTrace();
unknownData = nbt.copy();
}
}
NBTTagCompound plugs = nbt.getCompoundTag("plugs");
for (EnumFacing face : EnumFacing.VALUES) {
pluggables.get(face).readFromNbt(plugs.getCompoundTag(face.getName()));
}
wireManager.readFromNbt(nbt.getCompoundTag("wireManager"));
if (nbt.hasKey("redstone")) {
int[] temp = nbt.getIntArray("redstone");
if (temp.length == 6) {
redstoneValues = temp;
}
}
}
use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.
the class ActionType method readFromBuffer.
@Override
public ActionWrapper readFromBuffer(PacketBufferBC buffer) throws IOException {
if (buffer.readBoolean()) {
String name = buffer.readString();
EnumPipePart part = buffer.readEnumValue(EnumPipePart.class);
IStatement statement = StatementManager.statements.get(name);
if (statement instanceof IAction) {
return ActionWrapper.wrap(statement, part.face);
} else {
throw new InvalidInputDataException("Unknown action '" + name + "'");
}
} else {
return null;
}
}
use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.
the class TriggerType method readFromBuffer.
@Override
public TriggerWrapper readFromBuffer(PacketBufferBC buffer) throws IOException {
if (buffer.readBoolean()) {
String name = buffer.readString();
EnumPipePart part = buffer.readEnumValue(EnumPipePart.class);
IStatement statement = StatementManager.statements.get(name);
if (statement instanceof ITrigger) {
return TriggerWrapper.wrap(statement, part.face);
} else {
throw new InvalidInputDataException("Unknown trigger '" + name + "'");
}
} else {
return null;
}
}
use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.
the class TileReplacer method update.
@Override
public void update() {
if (world.isRemote) {
return;
}
if (!invSnapshot.getStackInSlot(0).isEmpty() && !invSchematicFrom.getStackInSlot(0).isEmpty() && !invSchematicTo.getStackInSlot(0).isEmpty()) {
Header header = BCBuildersItems.snapshot.getHeader(invSnapshot.getStackInSlot(0));
if (header != null) {
Snapshot snapshot = GlobalSavedDataSnapshots.get(world).getSnapshot(header.key);
if (snapshot instanceof Blueprint) {
Blueprint blueprint = (Blueprint) snapshot;
try {
ISchematicBlock from = SchematicBlockManager.readFromNBT(NBTUtilBC.getItemData(invSchematicFrom.getStackInSlot(0)).getCompoundTag(ItemSchematicSingle.NBT_KEY));
ISchematicBlock to = SchematicBlockManager.readFromNBT(NBTUtilBC.getItemData(invSchematicTo.getStackInSlot(0)).getCompoundTag(ItemSchematicSingle.NBT_KEY));
Blueprint newBlueprint = blueprint.copy();
newBlueprint.replace(from, to);
newBlueprint.computeKey();
GlobalSavedDataSnapshots.get(world).addSnapshot(newBlueprint);
invSnapshot.setStackInSlot(0, BCBuildersItems.snapshot.getUsed(EnumSnapshotType.BLUEPRINT, new Header(blueprint.key, getOwner().getId(), new Date(), header.name)));
invSchematicFrom.setStackInSlot(0, ItemStack.EMPTY);
invSchematicTo.setStackInSlot(0, ItemStack.EMPTY);
} catch (InvalidInputDataException e) {
e.printStackTrace();
}
}
}
}
}
use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.
the class SchematicBlockManager method readFromNBT.
@Nonnull
public static ISchematicBlock readFromNBT(NBTTagCompound schematicBlockTag) throws InvalidInputDataException {
ResourceLocation name = new ResourceLocation(schematicBlockTag.getString("name"));
SchematicBlockFactory<?> factory = SchematicBlockFactoryRegistry.getFactoryByName(name);
if (factory == null) {
throw new InvalidInputDataException("Unknown schematic type " + name);
}
ISchematicBlock schematicBlock = factory.supplier.get();
NBTTagCompound data = schematicBlockTag.getCompoundTag("data");
try {
schematicBlock.deserializeNBT(data);
return schematicBlock;
} catch (InvalidInputDataException e) {
throw new InvalidInputDataException("Failed to load the schematic from " + data, e);
}
}
Aggregations