Search in sources :

Example 1 with PlayerCollectionList

use of logisticspipes.utils.PlayerCollectionList in project LogisticsPipes by RS485.

the class MainProxy method isAnyoneWatching.

// ignores dimension; more stringent check done inside sendPacketToAllWatching
public static boolean isAnyoneWatching(int X, int Z, int dimensionID) {
    ChunkPos chunk = new ChunkPos(X >> 4, Z >> 4);
    PlayerCollectionList players = LogisticsEventListener.watcherList.get(chunk);
    if (players == null) {
        return false;
    }
    return !players.isEmptyWithoutCheck();
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList)

Example 2 with PlayerCollectionList

use of logisticspipes.utils.PlayerCollectionList in project LogisticsPipes by RS485.

the class MainProxy method sendPacketToAllWatchingChunk.

public static void sendPacketToAllWatchingChunk(int X, int Z, int dimensionId, ModernPacket packet) {
    if (!MainProxy.isServer()) {
        System.err.println("sendPacketToAllWatchingChunk called clientside !");
        new Exception().printStackTrace();
        return;
    }
    ChunkPos chunk = new ChunkPos(X >> 4, Z >> 4);
    PlayerCollectionList players = LogisticsEventListener.watcherList.get(chunk);
    if (players != null) {
        for (EntityPlayer player : players.players()) {
            if (player.world.provider.getDimension() == dimensionId) {
                MainProxy.sendPacketToPlayer(packet, player);
            }
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChunkPos(net.minecraft.util.math.ChunkPos) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList)

Example 3 with PlayerCollectionList

use of logisticspipes.utils.PlayerCollectionList in project LogisticsPipes by RS485.

the class LogisticsEventListener method watchChunk.

@SubscribeEvent
public void watchChunk(Watch event) {
    ChunkPos pos = event.getChunkInstance().getPos();
    if (!LogisticsEventListener.watcherList.containsKey(pos)) {
        LogisticsEventListener.watcherList.put(pos, new PlayerCollectionList());
    }
    LogisticsEventListener.watcherList.get(pos).add(event.getPlayer());
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

PlayerCollectionList (logisticspipes.utils.PlayerCollectionList)3 ChunkPos (net.minecraft.util.math.ChunkPos)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1