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();
}
}
}
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());
}
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"));
}
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;
}
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);
}
}
}
}
Aggregations