Search in sources :

Example 11 with InvalidInputDataException

use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.

the class SchematicBlockPipe method computeRequiredItems.

@Nonnull
@Override
public List<ItemStack> computeRequiredItems() {
    try {
        ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
        PipeDefinition definition = PipeRegistry.INSTANCE.loadDefinition(tileNbt.getCompoundTag("pipe").getString("def"));
        EnumDyeColor color = NBTUtilBC.readEnum(tileNbt.getCompoundTag("pipe").getTag("col"), EnumDyeColor.class);
        Item item = (Item) PipeApi.pipeRegistry.getItemForPipe(definition);
        if (item != null) {
            builder.add(new ItemStack(item, 1, color == null ? 0 : color.getMetadata() + 1));
        }
        return builder.build();
    } catch (InvalidInputDataException e) {
        throw new RuntimeException(e);
    }
}
Also used : Item(net.minecraft.item.Item) InvalidInputDataException(buildcraft.api.core.InvalidInputDataException) ImmutableList(com.google.common.collect.ImmutableList) PipeDefinition(buildcraft.api.transport.pipe.PipeDefinition) ItemStack(net.minecraft.item.ItemStack) EnumDyeColor(net.minecraft.item.EnumDyeColor) Nonnull(javax.annotation.Nonnull)

Example 12 with InvalidInputDataException

use of buildcraft.api.core.InvalidInputDataException in project BuildCraft by BuildCraft.

the class StatementTypeParam method readFromBuffer.

@Override
public IStatementParameter readFromBuffer(PacketBufferBC buffer) throws IOException {
    if (buffer.readBoolean()) {
        String tag = buffer.readString();
        IParamReaderBuf reader = StatementManager.paramsBuf.get(tag);
        if (reader == null) {
            throw new InvalidInputDataException("Unknown paramater type " + tag);
        }
        return reader.readFromBuf(buffer);
    } else {
        return null;
    }
}
Also used : InvalidInputDataException(buildcraft.api.core.InvalidInputDataException) IParamReaderBuf(buildcraft.api.statements.StatementManager.IParamReaderBuf)

Aggregations

InvalidInputDataException (buildcraft.api.core.InvalidInputDataException)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 Nonnull (javax.annotation.Nonnull)4 ISchematicBlock (buildcraft.api.schematics.ISchematicBlock)3 EnumPipePart (buildcraft.api.core.EnumPipePart)2 IStatement (buildcraft.api.statements.IStatement)2 ItemStack (net.minecraft.item.ItemStack)2 EnumFacing (net.minecraft.util.EnumFacing)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 BCLog (buildcraft.api.core.BCLog)1 EnumSnapshotType (buildcraft.api.enums.EnumSnapshotType)1 ISchematicEntity (buildcraft.api.schematics.ISchematicEntity)1 SchematicBlockContext (buildcraft.api.schematics.SchematicBlockContext)1 IAction (buildcraft.api.statements.IAction)1 ITrigger (buildcraft.api.statements.ITrigger)1 IParamReaderBuf (buildcraft.api.statements.StatementManager.IParamReaderBuf)1 IFlowItems (buildcraft.api.transport.pipe.IFlowItems)1 IItemPipe (buildcraft.api.transport.pipe.IItemPipe)1 IPipe (buildcraft.api.transport.pipe.IPipe)1 PipeDefinition (buildcraft.api.transport.pipe.PipeDefinition)1