Search in sources :

Example 1 with CCItemIdentifierStackImplementation

use of logisticspipes.proxy.computers.objects.CCItemIdentifierStack.CCItemIdentifierStackImplementation in project LogisticsPipes by RS485.

the class BaseWrapperClass method load.

@Override
public void load(NBTTagCompound nbt) {
    if (object != null) {
        return;
    }
    String type = nbt.getString("Type");
    if (type.equals("")) {
        return;
    }
    if (type.equals("LPGlobalCCAccess")) {
        object = LogisticsPipes.getComputerLP();
        checkType();
    } else if (type.equals("CoreRoutedPipe")) {
        int x = nbt.getInteger("X");
        int y = nbt.getInteger("Y");
        int z = nbt.getInteger("Z");
        final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
        final int dim = nbt.getInteger("Dim");
        QueuedTasks.queueTask(() -> {
            World world = DimensionManager.getWorld(dim);
            if (world != null) {
                TileEntity tile = pos.getTileEntity(world);
                if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
                    object = ((LogisticsTileGenericPipe) tile).pipe;
                    checkType();
                }
            }
            return null;
        });
    } else if (type.equals("CCItemIdentifierImplementation")) {
        ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
        if (stack != null) {
            object = new CCItemIdentifierImplementation(ItemIdentifier.get(stack));
            checkType();
        }
    } else if (type.equals("CCItemIdentifierStackImplementation")) {
        ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
        if (stack != null) {
            object = new CCItemIdentifierStackImplementation(ItemIdentifierStack.getFromStack(stack));
            checkType();
        }
    } else if (type.equals("CCItemIdentifierBuilder")) {
        ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
        if (stack != null) {
            CCItemIdentifierBuilder builder = new CCItemIdentifierBuilder();
            builder.setItemID(Double.valueOf(Item.getIdFromItem(stack.getItem())));
            builder.setItemData(Double.valueOf(stack.getItemDamage()));
            object = builder;
            checkType();
        }
    } else if (type.equals("LogisticsSolidTileEntity")) {
        int x = nbt.getInteger("X");
        int y = nbt.getInteger("Y");
        int z = nbt.getInteger("Z");
        final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
        final int dim = nbt.getInteger("Dim");
        QueuedTasks.queueTask(() -> {
            World world = DimensionManager.getWorld(dim);
            if (world != null) {
                TileEntity tile = pos.getTileEntity(world);
                if (tile instanceof LogisticsSolidTileEntity) {
                    object = tile;
                    checkType();
                }
            }
            return null;
        });
    } else {
        System.out.println("Unknown type to load");
    }
}
Also used : LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) CCItemIdentifierImplementation(logisticspipes.proxy.computers.objects.CCItemIdentifier.CCItemIdentifierImplementation) CCItemIdentifierBuilder(logisticspipes.proxy.computers.objects.CCItemIdentifierBuilder) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) CCItemIdentifierStackImplementation(logisticspipes.proxy.computers.objects.CCItemIdentifierStack.CCItemIdentifierStackImplementation)

Aggregations

LogisticsSolidTileEntity (logisticspipes.blocks.LogisticsSolidTileEntity)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)1 CCItemIdentifierImplementation (logisticspipes.proxy.computers.objects.CCItemIdentifier.CCItemIdentifierImplementation)1 CCItemIdentifierBuilder (logisticspipes.proxy.computers.objects.CCItemIdentifierBuilder)1 CCItemIdentifierStackImplementation (logisticspipes.proxy.computers.objects.CCItemIdentifierStack.CCItemIdentifierStackImplementation)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)1