use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class CoreRoutedPipe method doDebugStuff.
private void doDebugStuff(EntityPlayer entityplayer) {
//entityplayer.worldObj.setWorldTime(4951);
IRouter r = getRouter();
if (!(r instanceof ServerRouter)) {
return;
}
System.out.println("***");
System.out.println("---------Interests---------------");
for (Entry<ItemIdentifier, Set<IRouter>> i : ServerRouter.getInterestedInSpecifics().entrySet()) {
System.out.print(i.getKey().getFriendlyName() + ":");
for (IRouter j : i.getValue()) {
System.out.print(j.getSimpleID() + ",");
}
System.out.println();
}
System.out.print("ALL ITEMS:");
for (IRouter j : ServerRouter.getInterestedInGeneral()) {
System.out.print(j.getSimpleID() + ",");
}
System.out.println();
ServerRouter sr = (ServerRouter) r;
System.out.println(r.toString());
System.out.println("---------CONNECTED TO---------------");
for (CoreRoutedPipe adj : sr._adjacent.keySet()) {
System.out.println(adj.getRouter().getSimpleID());
}
System.out.println();
System.out.println("========DISTANCE TABLE==============");
for (ExitRoute n : r.getIRoutersByCost()) {
System.out.println(n.destination.getSimpleID() + " @ " + n.distanceToDestination + " -> " + n.connectionDetails + "(" + n.destination.getId() + ")");
}
System.out.println();
System.out.println("*******EXIT ROUTE TABLE*************");
List<List<ExitRoute>> table = r.getRouteTable();
for (int i = 0; i < table.size(); i++) {
if (table.get(i) != null) {
if (table.get(i).size() > 0) {
System.out.println(i + " -> " + table.get(i).get(0).destination.getSimpleID());
for (ExitRoute route : table.get(i)) {
System.out.println("\t\t via " + route.exitOrientation + "(" + route.distanceToDestination + " distance)");
}
}
}
}
System.out.println();
System.out.println("++++++++++CONNECTIONS+++++++++++++++");
System.out.println(Arrays.toString(ForgeDirection.VALID_DIRECTIONS));
System.out.println(Arrays.toString(sr.sideDisconnected));
System.out.println(Arrays.toString(container.pipeConnectionsBuffer));
System.out.println();
System.out.println("~~~~~~~~~~~~~~~POWER~~~~~~~~~~~~~~~~");
System.out.println(r.getPowerProvider());
System.out.println();
System.out.println("~~~~~~~~~~~SUBSYSTEMPOWER~~~~~~~~~~~");
System.out.println(r.getSubSystemPowerProvider());
System.out.println();
if (_orderItemManager != null) {
System.out.println("################ORDERDUMP#################");
_orderItemManager.dump();
}
System.out.println("################END#################");
refreshConnectionAndRender(true);
System.out.print("");
sr.CreateRouteTable(Integer.MAX_VALUE);
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class TDDuctInformationProvider method acceptItem.
@Override
public boolean acceptItem(LPTravelingItem item, TileEntity from) {
if (item instanceof LPTravelingItemServer) {
LPTravelingItemServer serverItem = (LPTravelingItemServer) item;
int id = serverItem.getInfo().destinationint;
if (id == -1) {
id = SimpleServiceLocator.routerManager.getIDforUUID(serverItem.getInfo().destinationUUID);
}
IRouter destination = SimpleServiceLocator.routerManager.getRouter(id);
if (destination == null) {
return false;
}
RouteCache routes = duct.getCache(true);
Iterable<Route> paramIterable = routes.outputRoutes;
Route route = null;
Object cache = null;
Triplet<Integer, ItemIdentifier, Boolean> key = new Triplet<>(id, item.getItemIdentifierStack().getItem(), serverItem.getInfo()._transportMode == TransportMode.Active);
if (duct instanceof ILPTEInformation && ((ILPTEInformation) duct).getObject() != null) {
cache = ((ILPTEInformation) duct).getObject().getCacheHolder().getCacheFor(CacheTypes.Routing, key);
}
if (cache instanceof Route) {
route = (Route) cache;
if (!routes.outputRoutes.contains(route)) {
route = null;
}
}
if (route == null) {
Pair<Double, Route> closesedConnection = null;
List<DoubleCoordinates> visited = new ArrayList<>();
visited.add(new DoubleCoordinates(from));
for (Route localRoute1 : paramIterable) {
if (localRoute1.endPoint instanceof LPItemDuct) {
LPItemDuct lpDuct = (LPItemDuct) localRoute1.endPoint;
double max = Integer.MAX_VALUE;
if (closesedConnection != null) {
max = closesedConnection.getValue1();
}
DoubleCoordinates pos = new DoubleCoordinates((TileEntity) lpDuct.pipe);
if (visited.contains(pos)) {
continue;
}
visited.add(pos);
double distance = lpDuct.pipe.getDistanceTo(id, ForgeDirection.getOrientation(localRoute1.pathDirections.get(localRoute1.pathDirections.size() - 1)).getOpposite(), item.getItemIdentifierStack().getItem(), serverItem.getInfo()._transportMode == TransportMode.Active, localRoute1.pathWeight, max, visited);
visited.remove(pos);
if (distance != Integer.MAX_VALUE && (closesedConnection == null || distance + localRoute1.pathDirections.size() < closesedConnection.getValue1())) {
closesedConnection = new Pair<>(distance + localRoute1.pathWeight, localRoute1);
}
}
}
if (closesedConnection != null) {
route = closesedConnection.getValue2();
}
}
if (route != null) {
if (duct instanceof ILPTEInformation && ((ILPTEInformation) duct).getObject() != null) {
((ILPTEInformation) duct).getObject().getCacheHolder().setCache(CacheTypes.Routing, key, route);
}
TravelingItem travelItem = new TravelingItem(item.getItemIdentifierStack().makeNormalStack(), duct, route.copy(), (byte) serverItem.output.ordinal(), (byte) 1);
travelItem.lpRoutingInformation = serverItem.getInfo();
duct.insertNewItem(travelItem);
return true;
}
} else {
return true;
}
return false;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class CrateInventoryHandler method decrStackSize.
@Override
public ItemStack decrStackSize(int i, int j) {
if (cached == null) {
initCache();
}
Entry<ItemIdentifier, Integer> entry = cached.get(i);
ItemStack stack = entry.getKey().makeNormalStack(j);
ItemStack extracted = null;
int count = _tile.getItemCount(stack);
if (count <= (_hideOnePerStack ? 1 : 0)) {
return null;
}
extracted = _tile.extractItems(stack, 1);
entry.setValue(entry.getValue() - j);
return extracted;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class DSUInventoryHandler method getItems.
@Override
public Set<ItemIdentifier> getItems() {
Set<ItemIdentifier> result = new TreeSet<>();
ItemStack items = _tile.getStoredItemType();
if (items != null && items.stackSize > 0) {
result.add(ItemIdentifier.get(items));
}
return result;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class RequestHandler method refresh.
public static void refresh(EntityPlayer player, CoreRoutedPipe pipe, DisplayOptions option) {
Map<ItemIdentifier, Integer> _availableItems;
LinkedList<ItemIdentifier> _craftableItems;
if (option == DisplayOptions.SupplyOnly || option == DisplayOptions.Both) {
_availableItems = SimpleServiceLocator.logisticsManager.getAvailableItems(pipe.getRouter().getIRoutersByCost());
} else {
_availableItems = new HashMap<>();
}
if (option == DisplayOptions.CraftOnly || option == DisplayOptions.Both) {
_craftableItems = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
} else {
_craftableItems = new LinkedList<>();
}
TreeSet<ItemIdentifierStack> _allItems = new TreeSet<>();
for (Entry<ItemIdentifier, Integer> item : _availableItems.entrySet()) {
ItemIdentifierStack newStack = item.getKey().makeStack(item.getValue());
_allItems.add(newStack);
}
for (ItemIdentifier item : _craftableItems) {
if (_availableItems.containsKey(item)) {
continue;
}
_allItems.add(item.makeStack(0));
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OrdererContent.class).setIdentSet(_allItems), player);
}
Aggregations