public void tickForward(DuctUnitItem homeTile) { progress += step; if (myPath == null) { bounceItem(homeTile); } else if (progress >= homeTile.getDuctLength()) { progress %= homeTile.getDuctLength(); advanceTile(homeTile); } else if (progress >= homeTile.getPipeHalfLength() && progress - step < homeTile.getPipeHalfLength()) { if (reRoute || homeTile.getRenderConnectionType(direction) == BlockDuct.ConnectionType.NONE) { bounceItem(homeTile); } } }
public void handlePacketType(PacketBase payload, int b) { if (b == TileInfoPackets.PULSE_LINE) { int c = payload.getByte(); for (int i = 0; i < 6; i++) { if ((c & (1 << i)) != 0) { centerLineSub[i] = MAX_CENTER_LINE; } } centerLine = MAX_CENTER_LINE; if (!TickHandlerClient.tickBlocks.contains(this) && !TickHandlerClient.tickBlocksToAdd.contains(this)) { TickHandlerClient.tickBlocksToAdd.add(this); } } else if (b == TileInfoPackets.TRAVELING_ITEMS) { myItems.clear(); byte n = payload.getByte(); if (n > 0) { for (byte i = 0; i < n; i++) { myItems.add(TravelingItem.fromPacket(payload, this)); } if (!TickHandlerClient.tickBlocks.contains(this) && !TickHandlerClient.tickBlocksToAdd.contains(this)) { TickHandlerClient.tickBlocksToAdd.add(this); } } } }
public void poll(TravelingItem item) { travelingItemsCount++; if (item.myPath == null) { return; } BlockPos dest = item.getDest(); StackMap list = travelingItems.computeIfAbsent(dest, k -> new StackMap()); list.addItemEntry(item.getStackEntry(), item.stack.getCount()); }
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); itemsToAdd.clear(); myItems.clear(); if (nbt.hasKey("TravellingItems", 9)) { NBTTagList list = nbt.getTagList("TravellingItems", 10); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); TravelingItem travelingItem = new TravelingItem(compound); if (!travelingItem.stack.isEmpty()) { myItems.add(travelingItem); } } } pathWeightType = nbt.getByte("Weight"); }
travelingItem.bounceItem(this); } else if (enderEnergy.getGrid() != null && enderEnergy.getGrid().myStorage.getEnergyStored() >= TDProps.ENDER_TRANSMIT_COST && enderEnergy.getGrid().myStorage.extractEnergy(TDProps.ENDER_TRANSMIT_COST, true) >= TDProps.ENDER_TRANSMIT_COST) { enderEnergy.getGrid().myStorage.extractEnergy(TDProps.ENDER_TRANSMIT_COST, false); multiAdvance(travelingItem, false); } else { travelingItem.tickForward(this);
public StackMap.ItemEntry getStackEntry() { if (stack.isEmpty()) { return null; } if (stackItemEntry == null || stackItemEntry.side != getLastSide()) { stackItemEntry = new StackMap.ItemEntry(stack, getLastSide()); } return stackItemEntry; }
public void tickItemsClient() { if (centerLine > 0) { centerLine--; for (int i = 0; i < 6; i++) { if (centerLineSub[i] > 0) { centerLineSub[i]--; } } } if (itemsToAdd.size() > 0) { myItems.addAll(itemsToAdd); itemsToAdd.clear(); } if (myItems.size() > 0) { for (TravelingItem myItem : myItems) { myItem.tickClientForward(this); } if (itemsToRemove.size() > 0) { myItems.removeAll(itemsToRemove); itemsToRemove.clear(); } } else if (centerLine == 0) { TickHandlerClient.tickBlocksToRemove.add(this); } }
public void tickItems() { if (itemsToAdd.size() > 0) { myItems.addAll(itemsToAdd); itemsToAdd.clear(); hasChanged = true; } if (myItems.size() > 0) { for (TravelingItem item : myItems) { item.tickForward(this); if (grid.repoll) { grid.poll(item); } } if (itemsToRemove.size() > 0) { myItems.removeAll(itemsToRemove); itemsToRemove.clear(); hasChanged = true; } } if (hasChanged) { sendTravelingItemsPacket(); hasChanged = false; } }
bounceItem(homeTile); return; } else { goingToStuff = false; bounceItem(homeTile); bounceItem(homeTile);
Route stuffedRoute = getStuffedRoute(routes); if (stuffedRoute != null) { goingToStuff = true;
public static TravelingItem fromPacket(PacketBase payload, DuctUnitItem homeTile) { return new TravelingItem(payload.getByte(), payload.getByte(), payload.getByte(), payload.getItemStack(), homeTile, payload.getByte()); }
public BlockPos getDest() { if (myPath == null) { return null; } if (myPath.dest == null) { if (myPath.endPoint == null) { if (!hasDest) { return null; } myPath.dest = (new BlockPos(destX, destY, destZ).offset(EnumFacing.VALUES[getLastSide()])); } else { myPath.dest = (new BlockPos(myPath.endPoint.x(), myPath.endPoint.y(), myPath.endPoint.z())).offset(EnumFacing.VALUES[getLastSide()]); } } return myPath.dest; }
public static TravelingItem findRouteForItem(ItemStack item, Iterator<Route<DuctUnitItem, GridItem>> routes, DuctUnitItem duct, int side, int maxRange, byte speed) { if (item.isEmpty() || item.getCount() == 0) { return null; } item = item.copy(); if (item.getCount() == 0) { return null; } while (routes.hasNext()) { Route<DuctUnitItem, GridItem> outputRoute = routes.next(); if (outputRoute.pathDirections.size() <= maxRange) { int amountRemaining = outputRoute.endPoint.canRouteItem(item, outputRoute.getLastSide()); if (amountRemaining != -1) { int stackSize = item.getCount() - amountRemaining; if (stackSize <= 0) { continue; } Route itemRoute = outputRoute.copy(); item.setCount(stackSize); return new TravelingItem(item, duct, itemRoute, (byte) (side ^ 1), speed); } } } return null; }
((ILPTEInformation) duct).getObject().getCacheHolder().setCache(CacheTypes.Routing, key, route); TravelingItem travelItem = new TravelingItem(item.getItemIdentifierStack().makeNormalStack(), duct.getDuct(DuctToken.ITEMS), route.copy(), (byte) serverItem.output.ordinal(), (byte) 1 /* Speed */ ); ((ILPTravelingItemInfo)travelItem).setLPRoutingInfoAddition(serverItem.getInfo()); duct.getDuct(DuctToken.ITEMS).insertNewItem(travelItem);
endPoint.insertNewItem(new TravelingItem(item, endPoint, route1, (byte) (i ^ 1), getSpeed())); routesWithInsertSideList.advanceCursor(); return;