Search in sources :

Example 46 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class RequestFluidOrdererRefreshPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    int dimension = getInteger();
    final LogisticsTileGenericPipe pipe = MainProxy.proxy.getPipeInDimensionAt(dimension, getPosX(), getPosY(), getPosZ(), player);
    if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
        return;
    }
    RequestHandler.refreshFluid(player, (CoreRoutedPipe) pipe.pipe);
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 47 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class RequestSubmitPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = MainProxy.proxy.getPipeInDimensionAt(getDimension(), getPosX(), getPosY(), getPosZ(), player);
    if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
        return;
    }
    RequestHandler.request(player, getStack(), (CoreRoutedPipe) pipe.pipe);
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 48 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class FindMostLikelyRecipeComponents method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    TileEntity tile = this.getTile(player.getEntityWorld(), TileEntity.class);
    CoreRoutedPipe pipe = null;
    if (tile instanceof LogisticsCraftingTableTileEntity) {
        for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
            TileEntity conn = CoordinateUtils.add(((LogisticsCraftingTableTileEntity) tile).getLPPosition(), dir).getTileEntity(player.getEntityWorld());
            if (conn instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) conn).pipe instanceof PipeItemsCraftingLogistics) {
                    pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe) conn).pipe;
                    break;
                }
            }
        }
    } else if (tile instanceof LogisticsTileGenericPipe) {
        if (((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
            pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe;
        }
    }
    List<Integer> list = new ArrayList<Integer>(content.size());
    while (list.size() < content.size()) {
        list.add(-1);
    }
    if (pipe == null)
        return;
    LinkedList<ItemIdentifier> craftable = null;
    for (int j = 0; j < content.size(); j++) {
        GuiRecipeImport.Canidates canidates = content.get(j);
        int maxItemPos = -1;
        int max = 0;
        for (int i = 0; i < canidates.order.size(); i++) {
            ItemIdentifier ident = canidates.order.get(i).getItem();
            int newAmount = SimpleServiceLocator.logisticsManager.getAmountFor(ident, pipe.getRouter().getIRoutersByCost());
            if (newAmount > max) {
                max = newAmount;
                maxItemPos = i;
            }
        }
        if (max < 64) {
            if (craftable == null) {
                craftable = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
            }
            for (ItemIdentifier craft : craftable) {
                for (int i = 0; i < canidates.order.size(); i++) {
                    ItemIdentifier ident = canidates.order.get(i).getItem();
                    if (craft == ident) {
                        maxItemPos = i;
                        break;
                    }
                }
            }
        }
        list.set(j, maxItemPos);
    }
    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MostLikelyRecipeComponentsResponse.class).setResponse(list), player);
}
Also used : GuiRecipeImport(logisticspipes.gui.popup.GuiRecipeImport) PipeItemsCraftingLogistics(logisticspipes.pipes.PipeItemsCraftingLogistics) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)

Example 49 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class RequestComponentPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = MainProxy.proxy.getPipeInDimensionAt(getDimension(), getPosX(), getPosY(), getPosZ(), player);
    if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
        return;
    }
    RequestHandler.simulate(player, getStack(), (CoreRoutedPipe) pipe.pipe);
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 50 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class ItemAmountSignUpdatePacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld());
    if (pipe == null || !pipe.isInitialized()) {
        return;
    }
    IPipeSign sign = ((CoreRoutedPipe) pipe.pipe).getPipeSign(ForgeDirection.getOrientation(getInteger()));
    if (sign == null) {
        return;
    }
    ((ItemAmountPipeSign) sign).amount = getInteger2();
    ((ItemAmountPipeSign) sign).itemTypeInv.setInventorySlotContents(0, stack);
}
Also used : IPipeSign(logisticspipes.pipes.signs.IPipeSign) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Aggregations

CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)68 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)43 TileEntity (net.minecraft.tileentity.TileEntity)22 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)16 ExitRoute (logisticspipes.routing.ExitRoute)15 ArrayList (java.util.ArrayList)14 LinkedList (java.util.LinkedList)13 IRouter (logisticspipes.routing.IRouter)11 Pair (logisticspipes.utils.tuples.Pair)10 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)10 List (java.util.List)9 HashMap (java.util.HashMap)8 IFilter (logisticspipes.interfaces.routing.IFilter)8 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 Map (java.util.Map)6 PipeRoutingConnectionType (logisticspipes.routing.PipeRoutingConnectionType)6 World (net.minecraft.world.World)6 BitSet (java.util.BitSet)5 Collections (java.util.Collections)5 EnumSet (java.util.EnumSet)5