Search in sources :

Example 1 with AsyncQuicksortModule

use of network.rs485.logisticspipes.module.AsyncQuicksortModule in project LogisticsPipes by RS485.

the class LogisticsEventListener method onPlayerLeftClickBlock.

@SubscribeEvent
public void onPlayerLeftClickBlock(final PlayerInteractEvent.RightClickBlock event) {
    if (MainProxy.isServer(event.getEntityPlayer().world)) {
        WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.getEntityPlayer().world, event.getPos());
        TileEntity tileEntity = worldCoordinates.getTileEntity();
        if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
            List<WeakReference<AsyncQuicksortModule>> list = worldCoordinates.allNeighborTileEntities().stream().filter(NeighborTileEntity::isLogisticsPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe instanceof PipeLogisticsChassis).filter(adjacent -> ((PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).getPointedOrientation() == adjacent.getOurDirection()).map(adjacent -> (PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).flatMap(chassis -> chassis.getModules().getModules()).filter(logisticsModule -> logisticsModule instanceof AsyncQuicksortModule).map(logisticsModule -> new WeakReference<>((AsyncQuicksortModule) logisticsModule)).collect(Collectors.toList());
            if (!list.isEmpty()) {
                LogisticsEventListener.chestQuickSortConnection.put(event.getEntityPlayer(), list);
            }
        }
    }
}
Also used : NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) PlayerEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent) MainProxy(logisticspipes.proxy.MainProxy) VersionChecker(logisticspipes.ticks.VersionChecker) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Configs(logisticspipes.config.Configs) TEControl(logisticspipes.routing.pathfinder.changedetection.TEControl) ChestGuiOpened(logisticspipes.network.packets.chassis.ChestGuiOpened) PlayerConfiguration(network.rs485.logisticspipes.config.PlayerConfiguration) Side(net.minecraftforge.fml.relauncher.Side) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) ClientConfiguration(network.rs485.logisticspipes.config.ClientConfiguration) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) Map(java.util.Map) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EntityItem(net.minecraft.entity.item.EntityItem) ChestGuiClosed(logisticspipes.network.packets.chassis.ChestGuiClosed) BlockEvent(net.minecraftforge.event.world.BlockEvent) UnWatch(net.minecraftforge.event.world.ChunkWatchEvent.UnWatch) WorldEvent(net.minecraftforge.event.world.WorldEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AsyncQuicksortModule(network.rs485.logisticspipes.module.AsyncQuicksortModule) ChunkPos(net.minecraft.util.math.ChunkPos) LPTickHandler(logisticspipes.ticks.LPTickHandler) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) PlayerLoggedOutEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent) List(java.util.List) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent) PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Queue(java.util.Queue) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) ClientConnectedToServerEvent(net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) PlayerLoggedInEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent) Setter(lombok.Setter) TextUtil(network.rs485.logisticspipes.util.TextUtil) 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) ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) WeakHashMap(java.util.WeakHashMap) ChatColor(logisticspipes.utils.string.ChatColor) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) GuiChest(net.minecraft.client.gui.inventory.GuiChest) TextComponentString(net.minecraft.util.text.TextComponentString) IBlockState(net.minecraft.block.state.IBlockState) GuiOpenEvent(net.minecraftforge.client.event.GuiOpenEvent) QuickSortChestMarkerStorage(logisticspipes.utils.QuickSortChestMarkerStorage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) TileEntity(net.minecraft.tileentity.TileEntity) AllArgsConstructor(lombok.AllArgsConstructor) TileEntityChest(net.minecraft.tileentity.TileEntityChest) AsyncQuicksortModule(network.rs485.logisticspipes.module.AsyncQuicksortModule) WeakReference(java.lang.ref.WeakReference) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with AsyncQuicksortModule

use of network.rs485.logisticspipes.module.AsyncQuicksortModule in project LogisticsPipes by RS485.

the class ChestGuiOpened method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    List<WeakReference<AsyncQuicksortModule>> list = LogisticsEventListener.chestQuickSortConnection.get(player);
    if (list == null || list.isEmpty()) {
        return;
    }
    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(EnableQuickSortMarker.class), player);
    for (WeakReference<AsyncQuicksortModule> sorter : list) {
        AsyncQuicksortModule module = sorter.get();
        if (module == null) {
            continue;
        }
        module.addWatchingPlayer(player);
    }
}
Also used : AsyncQuicksortModule(network.rs485.logisticspipes.module.AsyncQuicksortModule) WeakReference(java.lang.ref.WeakReference)

Example 3 with AsyncQuicksortModule

use of network.rs485.logisticspipes.module.AsyncQuicksortModule in project LogisticsPipes by RS485.

the class ChestGuiClosed method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    List<WeakReference<AsyncQuicksortModule>> list = LogisticsEventListener.chestQuickSortConnection.get(player);
    if (list == null || list.isEmpty()) {
        return;
    }
    for (WeakReference<AsyncQuicksortModule> sorter : list) {
        AsyncQuicksortModule module = sorter.get();
        if (module == null) {
            continue;
        }
        module.removeWatchingPlayer(player);
    }
    LogisticsEventListener.chestQuickSortConnection.remove(player);
}
Also used : AsyncQuicksortModule(network.rs485.logisticspipes.module.AsyncQuicksortModule) WeakReference(java.lang.ref.WeakReference)

Aggregations

WeakReference (java.lang.ref.WeakReference)3 AsyncQuicksortModule (network.rs485.logisticspipes.module.AsyncQuicksortModule)3 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Queue (java.util.Queue)1 WeakHashMap (java.util.WeakHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 Configs (logisticspipes.config.Configs)1 IItemAdvancedExistance (logisticspipes.interfaces.IItemAdvancedExistance)1 PacketHandler (logisticspipes.network.PacketHandler)1 PlayerConfigToClientPacket (logisticspipes.network.packets.PlayerConfigToClientPacket)1 ChestGuiClosed (logisticspipes.network.packets.chassis.ChestGuiClosed)1 ChestGuiOpened (logisticspipes.network.packets.chassis.ChestGuiOpened)1 GuiReopenPacket (logisticspipes.network.packets.gui.GuiReopenPacket)1 PipeLogisticsChassis (logisticspipes.pipes.PipeLogisticsChassis)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1