Search in sources :

Example 1 with LPTravelingItemServer

use of logisticspipes.transport.LPTravelingItem.LPTravelingItemServer in project LogisticsPipes by RS485.

the class ItemInsertionAIRobot method update.

@Override
public void update() {
    if (tick++ % 2 == 0) {
        Iterator<LPTravelingItemServer> iter = board.getItems().iterator();
        if (iter.hasNext()) {
            LPTravelingItemServer item = iter.next();
            LPTravelingItem.clientSideKnownIDs.set(item.getId(), false);
            pipe.pipe.transport.injectItem(item, insertion);
            // We clear the Inv at the end so we don't care if this fails
            robotInv.getMultipleItems(item.getItemIdentifierStack().getItem(), item.getItemIdentifierStack().getStackSize());
            iter.remove();
        } else {
            terminate();
        }
    }
}
Also used : LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Example 2 with LPTravelingItemServer

use of logisticspipes.transport.LPTravelingItem.LPTravelingItemServer in project LogisticsPipes by RS485.

the class LogisticsRoutingBoardRobot method writeSelfToNBT.

@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
    super.writeSelfToNBT(nbt);
    nbt.setInteger("LP_Item_Size", items.size());
    int count = 0;
    for (LPTravelingItemServer stack : items) {
        NBTTagCompound nbt_Sub = new NBTTagCompound();
        stack.writeToNBT(nbt_Sub);
        nbt.setTag("LP_Item_" + count++, nbt_Sub);
    }
    if (targetStationPos != null) {
        targetStationPos.writeToNBT("targetStationPos_", nbt);
    }
    nbt.setByte("targetStationSide", (byte) targetStationSide.ordinal());
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Example 3 with LPTravelingItemServer

use of logisticspipes.transport.LPTravelingItem.LPTravelingItemServer in project LogisticsPipes by RS485.

the class LogisticsRoutingBoardRobot method loadSelfFromNBT.

@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
    super.loadSelfFromNBT(nbt);
    items.clear();
    for (int i = 0; i < nbt.getInteger("LP_Item_Size"); i++) {
        if (nbt.hasKey("LP_Item_" + i)) {
            items.add(new LPTravelingItemServer(nbt.getCompoundTag("LP_Item_" + i)));
        }
    }
    targetStationPos = DoubleCoordinates.readFromNBT("targetStationPos_", nbt);
    targetStationSide = ForgeDirection.getOrientation(nbt.getByte("targetStationSide"));
}
Also used : LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Example 4 with LPTravelingItemServer

use of logisticspipes.transport.LPTravelingItem.LPTravelingItemServer in project LogisticsPipes by RS485.

the class BCPipeInformationProvider method acceptItem.

@Override
public boolean acceptItem(LPTravelingItem item, TileEntity from) {
    if (pipe != null && pipe.getPipe() != null && pipe.getPipe().getDefinition().flowType == PipeApi.flowItems) {
        if (!(item instanceof LPTravelingItemServer)) {
            return true;
        }
        ItemRoutingInformation routingInformation = ((LPTravelingItemServer) item).getInfo();
        NBTTagCompound routingData = new NBTTagCompound();
        routingInformation.storeToNBT(routingData);
        ItemStack transportStack = item.getItemIdentifierStack().makeNormalStack();
        if (!transportStack.hasTagCompound()) {
            transportStack.setTagCompound(new NBTTagCompound());
        }
        final NBTTagCompound tag = Objects.requireNonNull(transportStack.getTagCompound());
        tag.setTag("logisticspipes:routingdata_buildcraft", routingData);
        IFlowItems itemPipe = (IFlowItems) pipe.getPipe().getFlow();
        itemPipe.insertItemsForce(transportStack, item.output.getOpposite(), null, item.getSpeed());
        return true;
    }
    return false;
}
Also used : ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) IFlowItems(buildcraft.api.transport.pipe.IFlowItems) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Example 5 with LPTravelingItemServer

use of logisticspipes.transport.LPTravelingItem.LPTravelingItemServer in project LogisticsPipes by RS485.

the class CoreRoutedPipe method readFromNBT.

@Override
public void readFromNBT(@Nonnull NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    synchronized (routerIdLock) {
        routerId = nbttagcompound.getString("routerId");
    }
    stat_lifetime_sent = nbttagcompound.getLong("stat_lifetime_sent");
    stat_lifetime_recieved = nbttagcompound.getLong("stat_lifetime_recieved");
    stat_lifetime_relayed = nbttagcompound.getLong("stat_lifetime_relayed");
    if (getLogisticsModule() != null) {
        getLogisticsModule().readFromNBT(nbttagcompound);
    }
    upgradeManager.readFromNBT(nbttagcompound.getCompoundTag("upgradeManager"));
    powerHandler.readFromNBT(nbttagcompound.getCompoundTag("powerHandler"));
    _sendQueue.clear();
    NBTTagList sendqueue = nbttagcompound.getTagList("sendqueue", nbttagcompound.getId());
    for (int i = 0; i < sendqueue.tagCount(); i++) {
        NBTTagCompound tagentry = sendqueue.getCompoundTagAt(i);
        NBTTagCompound tagentityitem = tagentry.getCompoundTag("entityitem");
        LPTravelingItemServer item = new LPTravelingItemServer(tagentityitem);
        EnumFacing from = EnumFacing.values()[tagentry.getByte("from")];
        ItemSendMode mode = ItemSendMode.values()[tagentry.getByte("mode")];
        _sendQueue.add(new Triplet<>(item, from, mode));
    }
    for (int i = 0; i < 6; i++) {
        if (nbttagcompound.getBoolean("PipeSign_" + i)) {
            int type = nbttagcompound.getInteger("PipeSign_" + i + "_type");
            Class<? extends IPipeSign> typeClass = ItemPipeSignCreator.signTypes.get(type);
            try {
                signItem[i] = typeClass.newInstance();
                signItem[i].init(this, EnumFacingUtil.getOrientation(i));
                signItem[i].readFromNBT(nbttagcompound.getCompoundTag("PipeSign_" + i + "_tags"));
            } catch (InstantiationException | IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Aggregations

LPTravelingItemServer (logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)17 ItemRoutingInformation (logisticspipes.routing.ItemRoutingInformation)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 ItemStack (net.minecraft.item.ItemStack)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)3 DockingStation (buildcraft.api.robots.DockingStation)2 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)2 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)2 RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)2 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)2 ExitRoute (logisticspipes.routing.ExitRoute)2 Pair (logisticspipes.utils.tuples.Pair)2 Triplet (logisticspipes.utils.tuples.Triplet)2 IFlowItems (buildcraft.api.transport.pipe.IFlowItems)1 TileGenericPipe (buildcraft.transport.TileGenericPipe)1 DuctUnitItem (cofh.thermaldynamics.duct.item.DuctUnitItem)1 GridItem (cofh.thermaldynamics.duct.item.GridItem)1 TravelingItem (cofh.thermaldynamics.duct.item.TravelingItem)1