Search in sources :

Example 1 with LPTravelingItem

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

the class BCPipeInformationProvider method acceptItem.

@Override
public boolean acceptItem(LPTravelingItem item, TileEntity from) {
    if (BlockGenericPipe.isValid(pipe.pipe) && pipe.pipe.transport instanceof PipeTransportItems) {
        TravelingItem bcItem;
        if (item instanceof LPTravelingItemServer) {
            LPRoutedBCTravelingItem lpBCItem = new LPRoutedBCTravelingItem();
            lpBCItem.setRoutingInformation(((LPTravelingItemServer) item).getInfo());
            lpBCItem.saveToExtraNBTData();
            bcItem = lpBCItem;
        } else {
            return true;
        }
        DoubleCoordinates p = new DoubleCoordinates(pipe.xCoord + 0.5F, pipe.yCoord + CoreConstants.PIPE_MIN_POS, pipe.zCoord + 0.5F);
        double move;
        if (item.output.getOpposite() == ForgeDirection.DOWN) {
            move = 0.24;
        } else if (item.output.getOpposite() == ForgeDirection.UP) {
            move = 0.74;
        } else {
            move = 0.49;
        }
        CoordinateUtils.add(p, item.output.getOpposite(), move);
        bcItem.setPosition(p.getXCoord(), p.getYCoord(), p.getZCoord());
        bcItem.setSpeed(item.getSpeed());
        if (item.getItemIdentifierStack() != null) {
            bcItem.setItemStack(item.getItemIdentifierStack().makeNormalStack());
        }
        ((PipeTransportItems) pipe.pipe.transport).injectItem(bcItem, item.output);
        return true;
    }
    return false;
}
Also used : TravelingItem(buildcraft.transport.TravelingItem) LPTravelingItem(logisticspipes.transport.LPTravelingItem) PipeTransportItems(buildcraft.transport.PipeTransportItems) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Example 2 with LPTravelingItem

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

the class LogisticsRenderPipe method renderSolids.

private void renderSolids(CoreUnroutedPipe pipe, double x, double y, double z, float partialTickTime) {
    GL11.glPushMatrix();
    float light = pipe.container.getWorldObj().getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
    int count = 0;
    for (LPTravelingItem item : pipe.transport.items) {
        CoreUnroutedPipe lPipe = pipe;
        double lX = x;
        double lY = y;
        double lZ = z;
        float lItemYaw = item.getYaw();
        if (count >= LogisticsRenderPipe.MAX_ITEMS_TO_RENDER) {
            break;
        }
        if (item.getItemIdentifierStack() == null) {
            continue;
        }
        if (item.getContainer().xCoord != lPipe.container.xCoord || item.getContainer().yCoord != lPipe.container.yCoord || item.getContainer().zCoord != lPipe.container.zCoord) {
            continue;
        }
        if (item.getPosition() > lPipe.transport.getPipeLength() || item.getPosition() < 0) {
            continue;
        }
        float fPos = item.getPosition() + item.getSpeed() * partialTickTime;
        if (fPos > lPipe.transport.getPipeLength() && item.output != ForgeDirection.UNKNOWN) {
            CoreUnroutedPipe nPipe = lPipe.transport.getNextPipe(item.output);
            if (nPipe != null) {
                fPos -= lPipe.transport.getPipeLength();
                lX -= lPipe.getX() - nPipe.getX();
                lY -= lPipe.getY() - nPipe.getY();
                lZ -= lPipe.getZ() - nPipe.getZ();
                lItemYaw += lPipe.transport.getYawDiff(item);
                lPipe = nPipe;
                item = item.renderCopy();
                item.input = item.output;
                item.output = ForgeDirection.UNKNOWN;
            } else {
                continue;
            }
        }
        DoubleCoordinates pos = lPipe.getItemRenderPos(fPos, item);
        if (pos == null) {
            continue;
        }
        double boxScale = lPipe.getBoxRenderScale(fPos, item);
        double itemYaw = (lPipe.getItemRenderYaw(fPos, item) - lPipe.getItemRenderYaw(0, item) + lItemYaw) % 360;
        double itemPitch = lPipe.getItemRenderPitch(fPos, item);
        double itemYawForPitch = lPipe.getItemRenderYaw(fPos, item);
        ItemStack itemstack = item.getItemIdentifierStack().makeNormalStack();
        doRenderItem(itemstack, pipe.container.getWorldObj(), lX + pos.getXCoord(), lY + pos.getYCoord(), lZ + pos.getZCoord(), light, 0.75F, boxScale, itemYaw, itemPitch, itemYawForPitch, partialTickTime);
        count++;
    }
    count = 0;
    double dist = 0.135;
    DoubleCoordinates pos = new DoubleCoordinates(0.5, 0.5, 0.5);
    CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist);
    CoordinateUtils.add(pos, ForgeDirection.EAST, dist);
    CoordinateUtils.add(pos, ForgeDirection.UP, dist);
    for (Pair<ItemIdentifierStack, Pair<Integer, Integer>> item : pipe.transport._itemBuffer) {
        if (item == null || item.getValue1() == null) {
            continue;
        }
        ItemStack itemstack = item.getValue1().makeNormalStack();
        doRenderItem(itemstack, pipe.container.getWorldObj(), x + pos.getXCoord(), y + pos.getYCoord(), z + pos.getZCoord(), light, 0.25F, 0, 0, 0, 0, partialTickTime);
        count++;
        if (count >= 27) {
            break;
        } else if (count % 9 == 0) {
            CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist * 2.0);
            CoordinateUtils.add(pos, ForgeDirection.EAST, dist * 2.0);
            CoordinateUtils.add(pos, ForgeDirection.DOWN, dist);
        } else if (count % 3 == 0) {
            CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist * 2.0);
            CoordinateUtils.add(pos, ForgeDirection.WEST, dist);
        } else {
            CoordinateUtils.add(pos, ForgeDirection.NORTH, dist);
        }
    }
    GL11.glPopMatrix();
}
Also used : CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LPTravelingItem(logisticspipes.transport.LPTravelingItem) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemStack(net.minecraft.item.ItemStack) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) Pair(logisticspipes.utils.tuples.Pair)

Example 3 with LPTravelingItem

use of logisticspipes.transport.LPTravelingItem 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;
}
Also used : ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) Triplet(logisticspipes.utils.tuples.Triplet) ArrayList(java.util.ArrayList) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IRouter(logisticspipes.routing.IRouter) TravelingItem(cofh.thermaldynamics.duct.item.TravelingItem) LPTravelingItem(logisticspipes.transport.LPTravelingItem) RouteCache(cofh.thermaldynamics.multiblock.RouteCache) Route(cofh.thermaldynamics.multiblock.Route) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Aggregations

LPTravelingItem (logisticspipes.transport.LPTravelingItem)3 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)3 LPTravelingItemServer (logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)2 PipeTransportItems (buildcraft.transport.PipeTransportItems)1 TravelingItem (buildcraft.transport.TravelingItem)1 TravelingItem (cofh.thermaldynamics.duct.item.TravelingItem)1 Route (cofh.thermaldynamics.multiblock.Route)1 RouteCache (cofh.thermaldynamics.multiblock.RouteCache)1 ArrayList (java.util.ArrayList)1 ILPTEInformation (logisticspipes.asm.te.ILPTEInformation)1 CoreUnroutedPipe (logisticspipes.pipes.basic.CoreUnroutedPipe)1 IRouter (logisticspipes.routing.IRouter)1 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)1 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)1 Pair (logisticspipes.utils.tuples.Pair)1 Triplet (logisticspipes.utils.tuples.Triplet)1 ItemStack (net.minecraft.item.ItemStack)1