Search in sources :

Example 11 with WorldCoordinatesWrapper

use of network.rs485.logisticspipes.world.WorldCoordinatesWrapper in project LogisticsPipes by RS485.

the class PipeItemsBasicLogistics method getPointedInventory.

@Override
public IInventoryUtil getPointedInventory(boolean forExtraction) {
    IInventoryUtil inv = super.getPointedInventory(forExtraction);
    if (inv == null) {
        Optional<Pair<IInventory, ForgeDirection>> first = new WorldCoordinatesWrapper(container).getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IInventory).map(adjacentInventory -> new Pair<>(InventoryHelper.getInventory((IInventory) adjacentInventory.tileEntity), adjacentInventory.direction)).filter(inventoryDirectionPair -> inventoryDirectionPair.getValue1() != null).findFirst();
        if (first.isPresent()) {
            Pair<IInventory, ForgeDirection> p = first.get();
            inv = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(p.getValue1(), p.getValue2().getOpposite());
        }
    }
    return inv;
}
Also used : OrientationsUtil(logisticspipes.utils.OrientationsUtil) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) Textures(logisticspipes.textures.Textures) Item(net.minecraft.item.Item) TreeSet(java.util.TreeSet) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) InventoryHelper(logisticspipes.utils.InventoryHelper) ModulePositionType(logisticspipes.modules.abstractmodules.LogisticsModule.ModulePositionType) ConnectionPipeType(logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) TextureType(logisticspipes.textures.Textures.TextureType) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ModuleItemSink(logisticspipes.modules.ModuleItemSink) Pair(logisticspipes.utils.tuples.Pair) IInventory(net.minecraft.inventory.IInventory) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Optional(java.util.Optional) TileEntity(net.minecraft.tileentity.TileEntity) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) IInventory(net.minecraft.inventory.IInventory) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Pair(logisticspipes.utils.tuples.Pair)

Example 12 with WorldCoordinatesWrapper

use of network.rs485.logisticspipes.world.WorldCoordinatesWrapper in project LogisticsPipes by RS485.

the class CoreRoutedPipe method getConnectedRawInventories.

protected List<IInventory> getConnectedRawInventories() {
    if (_cachedAdjacentInventories == null) {
        WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(container);
        _cachedAdjacentInventories = worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IInventory).map(adjacent -> (IInventory) adjacent.tileEntity).collect(Collectors.toList());
    }
    return _cachedAdjacentInventories;
}
Also used : Arrays(java.util.Arrays) OrientationsUtil(logisticspipes.utils.OrientationsUtil) IRequireReliableFluidTransport(logisticspipes.interfaces.routing.IRequireReliableFluidTransport) IOrderInfoProvider(logisticspipes.routing.order.IOrderInfoProvider) MainProxy(logisticspipes.proxy.MainProxy) ILogisticsPowerProvider(logisticspipes.api.ILogisticsPowerProvider) Configs(logisticspipes.config.Configs) SinkReply(logisticspipes.utils.SinkReply) PipeController(logisticspipes.network.guis.pipe.PipeController) Map(java.util.Map) TransportLayer(logisticspipes.logisticspipes.TransportLayer) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) DebugLogController(logisticspipes.pipes.basic.debug.DebugLogController) NewGuiHandler(logisticspipes.network.NewGuiHandler) ILPPositionProvider(logisticspipes.interfaces.ILPPositionProvider) ModulePositionType(logisticspipes.modules.abstractmodules.LogisticsModule.ModulePositionType) CCConstants(logisticspipes.proxy.cc.CCConstants) LogisticsOrderManager(logisticspipes.routing.order.LogisticsOrderManager) PipeSignTypes(logisticspipes.network.packets.pipe.PipeSignTypes) CacheHolder(logisticspipes.utils.CacheHolder) LogisticsGuiModule(logisticspipes.modules.abstractmodules.LogisticsGuiModule) Set(java.util.Set) PacketHandler(logisticspipes.network.PacketHandler) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ExitRoute(logisticspipes.routing.ExitRoute) ISecurityProvider(logisticspipes.interfaces.ISecurityProvider) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IFilter(logisticspipes.interfaces.routing.IFilter) IClientState(logisticspipes.interfaces.IClientState) ParticleFX(logisticspipes.network.packets.pipe.ParticleFX) PipeFXRenderHandler(logisticspipes.pipefxhandlers.PipeFXRenderHandler) FluidStack(net.minecraftforge.fluids.FluidStack) ModDependentMethod(logisticspipes.asm.ModDependentMethod) ITrackStatistics(logisticspipes.logisticspipes.ITrackStatistics) ArrayList(java.util.ArrayList) StatUpdate(logisticspipes.network.packets.pipe.StatUpdate) UpgradeManager(logisticspipes.pipes.upgrades.UpgradeManager) ItemStack(net.minecraft.item.ItemStack) ISubSystemPowerProvider(logisticspipes.interfaces.ISubSystemPowerProvider) StatusEntry(logisticspipes.pipes.basic.debug.StatusEntry) IWorldProvider(logisticspipes.interfaces.IWorldProvider) LogisticsItemOrderManager(logisticspipes.routing.order.LogisticsItemOrderManager) World(net.minecraft.world.World) SecuritySettings(logisticspipes.security.SecuritySettings) IPipeUpgradeManager(logisticspipes.interfaces.IPipeUpgradeManager) TreeMap(java.util.TreeMap) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) IWatchingHandler(logisticspipes.interfaces.IWatchingHandler) PipeTransportLayer(logisticspipes.logisticspipes.PipeTransportLayer) TileEntity(net.minecraft.tileentity.TileEntity) IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) IRouter(logisticspipes.routing.IRouter) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) Textures(logisticspipes.textures.Textures) Item(net.minecraft.item.Item) LogisticsPipes(logisticspipes.LogisticsPipes) Particles(logisticspipes.pipefxhandlers.Particles) Random(java.util.Random) CCType(logisticspipes.proxy.computers.interfaces.CCType) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) IRequireReliableTransport(logisticspipes.interfaces.routing.IRequireReliableTransport) NBTTagList(net.minecraft.nbt.NBTTagList) FluidIdentifier(logisticspipes.utils.FluidIdentifier) SidedInventoryMinecraftAdapter(logisticspipes.utils.SidedInventoryMinecraftAdapter) CCCommand(logisticspipes.proxy.computers.interfaces.CCCommand) ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) IAdditionalTargetInformation(logisticspipes.interfaces.routing.IAdditionalTargetInformation) IQueueCCEvent(logisticspipes.interfaces.IQueueCCEvent) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) ConnectionPipeType(logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) RouteLayer(logisticspipes.logisticspipes.RouteLayer) Triplet(logisticspipes.utils.tuples.Triplet) UUID(java.util.UUID) IHighlightPlacementRenderer(logisticspipes.renderer.newpipe.IHighlightPlacementRenderer) LPDataOutput(network.rs485.logisticspipes.util.LPDataOutput) Collectors(java.util.stream.Collectors) TransportMode(logisticspipes.logisticspipes.IRoutedItem.TransportMode) ServerRouter(logisticspipes.routing.ServerRouter) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemPipeSignCreator(logisticspipes.items.ItemPipeSignCreator) List(java.util.List) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) Queue(java.util.Queue) GuiIDs(logisticspipes.network.GuiIDs) IPipeSign(logisticspipes.pipes.signs.IPipeSign) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Getter(lombok.Getter) CCSecurtiyCheck(logisticspipes.proxy.computers.interfaces.CCSecurtiyCheck) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) RequestSignPacket(logisticspipes.network.packets.pipe.RequestSignPacket) PermissionException(logisticspipes.security.PermissionException) CrashReportCategory(net.minecraft.crash.CrashReportCategory) Minecraft(net.minecraft.client.Minecraft) IRequestItems(logisticspipes.interfaces.routing.IRequestItems) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager) ExtractionMode(logisticspipes.logisticspipes.ExtractionMode) ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer) LinkedList(java.util.LinkedList) LPConstants(logisticspipes.LPConstants) InventoryHelper(logisticspipes.utils.InventoryHelper) LPDataInput(network.rs485.logisticspipes.util.LPDataInput) CCDirectCall(logisticspipes.proxy.computers.interfaces.CCDirectCall) TextureType(logisticspipes.textures.Textures.TextureType) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics) IInventory(net.minecraft.inventory.IInventory) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) BitSet(java.util.BitSet) Collections(java.util.Collections) IInventory(net.minecraft.inventory.IInventory) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper)

Example 13 with WorldCoordinatesWrapper

use of network.rs485.logisticspipes.world.WorldCoordinatesWrapper in project LogisticsPipes by RS485.

the class PowerSupplierHandler method update.

public void update() {
    if (SimpleServiceLocator.cofhPowerProxy.isAvailable() && pipe.getUpgradeManager().hasRFPowerSupplierUpgrade()) {
        //Use Buffer
        Stream<AdjacentTileEntity> adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        double globalNeed = 0;
        double[] need = new double[(int) adjacentTileEntityStream.count()];
        adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        int i = 0;
        Iterator<AdjacentTileEntity> adjacentIt = adjacentTileEntityStream.iterator();
        while (adjacentIt.hasNext()) {
            AdjacentTileEntity adjacent = adjacentIt.next();
            if (SimpleServiceLocator.cofhPowerProxy.isEnergyReceiver(adjacent.tileEntity)) {
                if (pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction)) {
                    ICoFHEnergyReceiver energyReceiver = SimpleServiceLocator.cofhPowerProxy.getEnergyReceiver(adjacent.tileEntity);
                    ForgeDirection oppositeDir = adjacent.direction.getOpposite();
                    if (energyReceiver.canConnectEnergy(oppositeDir)) {
                        globalNeed += need[i] = (energyReceiver.getMaxEnergyStored(oppositeDir) - energyReceiver.getEnergyStored(oppositeDir));
                    }
                }
            }
            ++i;
        }
        if (globalNeed != 0 && !Double.isNaN(globalNeed)) {
            double fullfillable = Math.min(1, internalBufferRF / globalNeed);
            i = 0;
            adjacentIt = adjacentTileEntityStream.iterator();
            while (adjacentIt.hasNext()) {
                AdjacentTileEntity adjacent = adjacentIt.next();
                if (SimpleServiceLocator.cofhPowerProxy.isEnergyReceiver(adjacent.tileEntity)) {
                    if (pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction)) {
                        ICoFHEnergyReceiver energyReceiver = SimpleServiceLocator.cofhPowerProxy.getEnergyReceiver(adjacent.tileEntity);
                        ForgeDirection oppositeDir = adjacent.direction.getOpposite();
                        if (energyReceiver.canConnectEnergy(oppositeDir)) {
                            if (internalBufferRF + 1 < need[i] * fullfillable) {
                                return;
                            }
                            int used = energyReceiver.receiveEnergy(oppositeDir, (int) (need[i] * fullfillable), false);
                            if (used > 0) {
                                pipe.container.addLaser(adjacent.direction, 0.5F, LogisticsPowerProviderTileEntity.RF_COLOR, false, true);
                                internalBufferRF -= used;
                            }
                            if (internalBufferRF < 0) {
                                internalBufferRF = 0;
                                return;
                            }
                        }
                    }
                }
                ++i;
            }
        }
        //Rerequest Buffer
        List<Pair<ISubSystemPowerProvider, List<IFilter>>> provider = pipe.getRouter().getSubSystemPowerProvider();
        double available = 0;
        outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
            for (IFilter filter : pair.getValue2()) {
                if (filter.blockPower()) {
                    continue outer;
                }
            }
            if (pair.getValue1().usePaused()) {
                continue;
            }
            if (!pair.getValue1().getBrand().equals("RF")) {
                continue;
            }
            available += pair.getValue1().getPowerLevel();
        }
        if (available > 0) {
            double neededPower = PowerSupplierHandler.INTERNAL_RF_BUFFER_MAX - internalBufferRF;
            if (neededPower > 0) {
                if (pipe.useEnergy((int) (neededPower / 100), false)) {
                    outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
                        for (IFilter filter : pair.getValue2()) {
                            if (filter.blockPower()) {
                                continue outer;
                            }
                        }
                        if (pair.getValue1().usePaused()) {
                            continue;
                        }
                        if (!pair.getValue1().getBrand().equals("RF")) {
                            continue;
                        }
                        double requestamount = neededPower * (pair.getValue1().getPowerLevel() / available);
                        pair.getValue1().requestPower(pipe.getRouterId(), requestamount);
                    }
                }
            }
        }
    }
    if (SimpleServiceLocator.IC2Proxy.hasIC2() && pipe.getUpgradeManager().getIC2PowerLevel() > 0) {
        //Use Buffer
        Stream<AdjacentTileEntity> adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        double globalNeed = 0;
        double[] need = new double[(int) adjacentTileEntityStream.count()];
        adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        int i = 0;
        Iterator<AdjacentTileEntity> adjacentIt = adjacentTileEntityStream.iterator();
        while (adjacentIt.hasNext()) {
            AdjacentTileEntity adjacent = adjacentIt.next();
            if (SimpleServiceLocator.IC2Proxy.isEnergySink(adjacent.tileEntity)) {
                if (pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction)) {
                    if (SimpleServiceLocator.IC2Proxy.acceptsEnergyFrom(adjacent.tileEntity, pipe.container, adjacent.direction.getOpposite())) {
                        globalNeed += need[i] = SimpleServiceLocator.IC2Proxy.demandedEnergyUnits(adjacent.tileEntity);
                    }
                }
            }
            ++i;
        }
        if (globalNeed != 0 && !Double.isNaN(globalNeed)) {
            double fullfillable = Math.min(1, internalBufferIC2 / globalNeed);
            i = 0;
            adjacentIt = adjacentTileEntityStream.iterator();
            while (adjacentIt.hasNext()) {
                AdjacentTileEntity adjacent = adjacentIt.next();
                if (SimpleServiceLocator.IC2Proxy.isEnergySink(adjacent.tileEntity) && pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction) && SimpleServiceLocator.IC2Proxy.acceptsEnergyFrom(adjacent.tileEntity, pipe.container, adjacent.direction.getOpposite())) {
                    if (internalBufferIC2 + 1 < need[i] * fullfillable) {
                        return;
                    }
                    double toUse = Math.min(pipe.getUpgradeManager().getIC2PowerLevel(), need[i] * fullfillable);
                    double unUsed = SimpleServiceLocator.IC2Proxy.injectEnergyUnits(adjacent.tileEntity, adjacent.direction.getOpposite(), toUse);
                    double used = toUse - unUsed;
                    if (used > 0) {
                        //MainProxy.sendPacketToAllWatchingChunk(this.pipe.getX(), this.pipe.getZ(), MainProxy.getDimensionForWorld(this.pipe.getWorld()), PacketHandler.getPacket(PowerPacketLaser.class).setColor(LogisticsPowerProviderTileEntity.IC2_COLOR).setPos(this.pipe.getLPPosition()).setRenderBall(true).setDir(adTile.orientation).setLength(0.5F));
                        pipe.container.addLaser(adjacent.direction, 0.5F, LogisticsPowerProviderTileEntity.IC2_COLOR, false, true);
                        internalBufferIC2 -= used;
                    }
                    if (internalBufferIC2 < 0) {
                        internalBufferIC2 = 0;
                        return;
                    }
                }
                ++i;
            }
        }
        //Rerequest Buffer
        List<Pair<ISubSystemPowerProvider, List<IFilter>>> provider = pipe.getRouter().getSubSystemPowerProvider();
        double available = 0;
        outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
            for (IFilter filter : pair.getValue2()) {
                if (filter.blockPower()) {
                    continue outer;
                }
            }
            if (pair.getValue1().usePaused()) {
                continue;
            }
            if (!pair.getValue1().getBrand().equals("EU")) {
                continue;
            }
            available += pair.getValue1().getPowerLevel();
        }
        if (available > 0) {
            double neededPower = PowerSupplierHandler.INTERNAL_IC2_BUFFER_MAX - internalBufferIC2;
            if (neededPower > 0) {
                if (pipe.useEnergy((int) (neededPower / 10000), false)) {
                    outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
                        for (IFilter filter : pair.getValue2()) {
                            if (filter.blockPower()) {
                                continue outer;
                            }
                        }
                        if (pair.getValue1().usePaused()) {
                            continue;
                        }
                        if (!pair.getValue1().getBrand().equals("EU")) {
                            continue;
                        }
                        double requestamount = neededPower * (pair.getValue1().getPowerLevel() / available);
                        pair.getValue1().requestPower(pipe.getRouterId(), requestamount);
                    }
                }
            }
        }
    }
}
Also used : IFilter(logisticspipes.interfaces.routing.IFilter) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) AdjacentTileEntity(network.rs485.logisticspipes.world.WorldCoordinatesWrapper.AdjacentTileEntity) ICoFHEnergyReceiver(logisticspipes.proxy.cofh.subproxies.ICoFHEnergyReceiver) Pair(logisticspipes.utils.tuples.Pair)

Example 14 with WorldCoordinatesWrapper

use of network.rs485.logisticspipes.world.WorldCoordinatesWrapper in project LogisticsPipes by RS485.

the class LogisticsTileGenericPipe method scheduleNeighborChange.

@Override
public void scheduleNeighborChange() {
    tilePart.scheduleNeighborChange();
    tdPart.scheduleNeighborChange();
    blockNeighborChange = true;
    boolean[] connected = new boolean[6];
    new WorldCoordinatesWrapper(this).getAdjacentTileEntities().filter(adjacent -> SimpleServiceLocator.ccProxy.isTurtle(adjacent.tileEntity)).forEach(adjacent -> connected[adjacent.direction.ordinal()] = true);
    for (int i = 0; i < 6; i++) {
        if (!connected[i]) {
            turtleConnect[i] = false;
        }
    }
}
Also used : Arrays(java.util.Arrays) ILPPipe(logisticspipes.api.ILPPipe) OrientationsUtil(logisticspipes.utils.OrientationsUtil) ModDependentField(logisticspipes.asm.ModDependentField) IPipeConnection(buildcraft.api.transport.IPipeConnection) Item(net.minecraft.item.Item) LogisticsPipes(logisticspipes.LogisticsPipes) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) Level(org.apache.logging.log4j.Level) IPipeInformationProvider(logisticspipes.routing.pathfinder.IPipeInformationProvider) MainProxy(logisticspipes.proxy.MainProxy) Block(net.minecraft.block.Block) StackTraceUtil(logisticspipes.utils.StackTraceUtil) ITDPart(logisticspipes.proxy.td.subproxies.ITDPart) Fluid(net.minecraftforge.fluids.Fluid) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) PipeTileStatePacket(logisticspipes.network.packets.pipe.PipeTileStatePacket) Packet(net.minecraft.network.Packet) Side(cpw.mods.fml.relauncher.Side) LogisticsTileRenderController(logisticspipes.renderer.LogisticsTileRenderController) SideOnly(cpw.mods.fml.relauncher.SideOnly) CCObjectWrapper(logisticspipes.proxy.computers.wrapper.CCObjectWrapper) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) PacketHandler(logisticspipes.network.PacketHandler) IBCTilePart(logisticspipes.proxy.buildcraft.subproxies.IBCTilePart) IConnectionOverrideResult(logisticspipes.proxy.buildcraft.subproxies.IConnectionOverrideResult) LPDataOutput(network.rs485.logisticspipes.util.LPDataOutput) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Info(logisticspipes.utils.StackTraceUtil.Info) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) Stream(java.util.stream.Stream) SidedEnvironment(li.cil.oc.api.network.SidedEnvironment) IOCTile(logisticspipes.proxy.opencomputers.IOCTile) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) IFilter(logisticspipes.interfaces.routing.IFilter) LogicController(logisticspipes.logic.LogicController) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IClientState(logisticspipes.interfaces.IClientState) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) FluidStack(net.minecraftforge.fluids.FluidStack) TileGenericPipe(buildcraft.transport.TileGenericPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) PipeRenderState(logisticspipes.renderer.state.PipeRenderState) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) ILPPipeTile(logisticspipes.api.ILPPipeTile) IPipe(buildcraft.api.transport.IPipe) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) Context(li.cil.oc.api.machine.Context) Message(li.cil.oc.api.network.Message) Getter(lombok.Getter) HashMap(java.util.HashMap) ModDependentMethod(logisticspipes.asm.ModDependentMethod) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) BaseWrapperClass(logisticspipes.proxy.opencomputers.asm.BaseWrapperClass) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ModDependentInterface(logisticspipes.asm.ModDependentInterface) Environment(li.cil.oc.api.network.Environment) IBCPluggableState(logisticspipes.proxy.buildcraft.subproxies.IBCPluggableState) LPConstants(logisticspipes.LPConstants) Node(li.cil.oc.api.network.Node) LPDataInput(network.rs485.logisticspipes.util.LPDataInput) World(net.minecraft.world.World) Arguments(li.cil.oc.api.machine.Arguments) IPipeTile(buildcraft.api.transport.IPipeTile) IItemDuct(cofh.api.transport.IItemDuct) ManagedPeripheral(li.cil.oc.api.network.ManagedPeripheral) EnumColor(buildcraft.api.core.EnumColor) TileBuffer(logisticspipes.utils.TileBuffer) IComputerAccess(dan200.computercraft.api.peripheral.IComputerAccess) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) ILogicControllerTile(logisticspipes.logic.interfaces.ILogicControllerTile) IIconProvider(logisticspipes.renderer.IIconProvider) TileEntity(net.minecraft.tileentity.TileEntity) LPTravelingItem(logisticspipes.transport.LPTravelingItem) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper)

Example 15 with WorldCoordinatesWrapper

use of network.rs485.logisticspipes.world.WorldCoordinatesWrapper in project LogisticsPipes by RS485.

the class LogisticsEventListener method onPlayerInteract.

@SubscribeEvent
public void onPlayerInteract(final PlayerInteractEvent event) {
    if (MainProxy.isServer(event.entityPlayer.worldObj)) {
        if (event.action == Action.LEFT_CLICK_BLOCK) {
            final TileEntity tile = event.entityPlayer.worldObj.getTileEntity(event.x, event.y, event.z);
            if (tile instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
                    if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.entityPlayer)) {
                        event.setCanceled(true);
                        event.entityPlayer.addChatComponentMessage(new ChatComponentTranslation("lp.chat.permissiondenied"));
                        ((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
                        event.entityPlayer.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
                        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
                        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
                    } else {
                        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
                    }
                }
            }
        }
        if (event.action == Action.RIGHT_CLICK_BLOCK) {
            WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.entityPlayer.worldObj, event.x, event.y, event.z);
            TileEntity tileEntity = worldCoordinates.getTileEntity();
            if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
                //@formatter:off
                List<WeakReference<ModuleQuickSort>> list = worldCoordinates.getAdjacentTileEntities().filter(adjacent -> adjacent.tileEntity instanceof LogisticsTileGenericPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe instanceof PipeLogisticsChassi).filter(adjacent -> ((PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).getPointedOrientation() == adjacent.direction.getOpposite()).map(adjacent -> (PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).flatMap(pipeLogisticsChassi -> Arrays.stream(pipeLogisticsChassi.getModules().getModules())).filter(logisticsModule -> logisticsModule instanceof ModuleQuickSort).map(logisticsModule -> new WeakReference<>((ModuleQuickSort) logisticsModule)).collect(Collectors.toList());
                if (!list.isEmpty()) {
                    LogisticsEventListener.chestQuickSortConnection.put(event.entityPlayer, list);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Action(net.minecraftforge.event.entity.player.PlayerInteractEvent.Action) Arrays(java.util.Arrays) ModuleQuickSort(logisticspipes.modules.ModuleQuickSort) MainProxy(logisticspipes.proxy.MainProxy) VersionChecker(logisticspipes.ticks.VersionChecker) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) Configs(logisticspipes.config.Configs) ChestGuiOpened(logisticspipes.network.packets.chassis.ChestGuiOpened) ChatComponentText(net.minecraft.util.ChatComponentText) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) Map(java.util.Map) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) PlayerLoggedInEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent) PlayerLoggedOutEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent) ClientConnectedToServerEvent(cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) EntityItem(net.minecraft.entity.item.EntityItem) ChestGuiClosed(logisticspipes.network.packets.chassis.ChestGuiClosed) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) UnWatch(net.minecraftforge.event.world.ChunkWatchEvent.UnWatch) WorldEvent(net.minecraftforge.event.world.WorldEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) List(java.util.List) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Queue(java.util.Queue) PlayerConfig(logisticspipes.config.PlayerConfig) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) Setter(lombok.Setter) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) GuiReopenPacket(logisticspipes.network.packets.gui.GuiReopenPacket) HashMap(java.util.HashMap) PlayerConfigToClientPacket(logisticspipes.network.packets.PlayerConfigToClientPacket) Watch(net.minecraftforge.event.world.ChunkWatchEvent.Watch) TileEntityChest(net.minecraft.tileentity.TileEntityChest) ItemStack(net.minecraft.item.ItemStack) IItemAdvancedExistance(logisticspipes.interfaces.IItemAdvancedExistance) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent) WeakHashMap(java.util.WeakHashMap) IOException(java.io.IOException) GuiChest(net.minecraft.client.gui.inventory.GuiChest) GuiOpenEvent(net.minecraftforge.client.event.GuiOpenEvent) QuickSortChestMarkerStorage(logisticspipes.utils.QuickSortChestMarkerStorage) TileEntity(net.minecraft.tileentity.TileEntity) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) AllArgsConstructor(lombok.AllArgsConstructor) TileEntityChest(net.minecraft.tileentity.TileEntityChest) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) WeakReference(java.lang.ref.WeakReference) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ModuleQuickSort(logisticspipes.modules.ModuleQuickSort) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

WorldCoordinatesWrapper (network.rs485.logisticspipes.world.WorldCoordinatesWrapper)18 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)12 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)12 IFilter (logisticspipes.interfaces.routing.IFilter)10 List (java.util.List)9 Pair (logisticspipes.utils.tuples.Pair)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)9 TileEntity (net.minecraft.tileentity.TileEntity)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 LinkedList (java.util.LinkedList)8 PacketHandler (logisticspipes.network.PacketHandler)8 MainProxy (logisticspipes.proxy.MainProxy)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 PlayerCollectionList (logisticspipes.utils.PlayerCollectionList)7 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)7 ItemStack (net.minecraft.item.ItemStack)7 HashMap (java.util.HashMap)6 Set (java.util.Set)6