Java 类net.minecraft.server.management.PlayerChunkMapEntry 实例源码

项目:PurificatiMagicae    文件:SifStorageServer.java   
@Override
public void set(GlobalChunkPos pos, float value)
{
    if (loaded.containsKey(pos))
        if (loaded.get(pos).equals(value))
            return;
    loaded.put(pos, value);
    WorldServer wrld = DimensionManager.getWorld(pos.getDimension());
    wrld.getChunkFromChunkCoords(pos.getX(), pos.getZ()).markDirty();
    PlayerChunkMapEntry map = wrld.getPlayerChunkMap().getEntry(pos.getX(), pos.getZ());
    if (map != null)
    {
        for (EntityPlayerMP p : map.players)
        {
            NetworkManager.sendTo(new CPacketSyncSif(pos, value), p);
        }
    }
}
项目:CrystalMod    文件:ExplosionMaker.java   
private void removeBlock(BlockPos pos) {
    if(pos.getY() < 0 || pos.getY() >= 256)return;
    Chunk chunk = getChunk(pos);
    IBlockState oldState = chunk.getBlockState(pos);

    if (oldState.getBlock().hasTileEntity(oldState)) {
        serverWorld.setBlockToAir(pos);

        PlayerChunkMap playerChunkMap = serverWorld.getPlayerChunkMap();
        if (playerChunkMap != null) {
            PlayerChunkMapEntry watcher = playerChunkMap.getEntry(pos.getX() >> 4, pos.getZ() >> 4);
            if (watcher != null) {
                watcher.sendPacket(new SPacketBlockChange(serverWorld, pos));
            }
        }
    }

    ExtendedBlockStorage storage = getBlockStorage(pos);
    if(storage !=null){
        storage.set(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15, AIR);
    }
    setChunkModified(pos);
}
项目:CrystalMod    文件:ExplosionMaker.java   
public void finishChunks() {
    PlayerChunkMap playerChunkMap = serverWorld.getPlayerChunkMap();
    if (playerChunkMap == null) {
        return;
    }

    for (Chunk chunk : modifiedChunks) {
        chunk.setModified(true);
        chunk.generateSkylightMap(); //This is where this falls short. It can calculate basic sky lighting for blocks exposed to the sky but thats it.

        PlayerChunkMapEntry watcher = playerChunkMap.getEntry(chunk.xPosition, chunk.zPosition);
        if (watcher != null) {
            watcher.sendPacket(new SPacketChunkData(chunk, 65535));
        }
    }

    modifiedChunks.clear();
}
项目:HardVox    文件:OpSendChunks.java   
@Override
public int performOperation(Region region, PositionIterator chunk, World world, Chunk c, VectorMap<BlockData> blockMap,
        MutableVectorMap<IBlockState> hitStore) {
    // send the whole chunk again
    PlayerChunkMapEntry entry = ((WorldServer) world).getPlayerChunkMap().getEntry(c.x, c.z);
    if (entry != null) {
        entry.sendPacket(new SPacketChunkData(c, SPCD_SEND_ALL));
    }
    return 1;
}
项目:PurificatiMagicae    文件:SifStorageServer.java   
@Override
public void remove(GlobalChunkPos pos)
{
    if (!loaded.containsKey(pos))
        return;
    loaded.remove(pos);
    PlayerChunkMapEntry map = DimensionManager.getWorld(pos.getDimension()).getPlayerChunkMap().getEntry(pos.getX(), pos.getZ());
    if (map != null)
    {
        for (EntityPlayerMP p : map.players)
        {
            NetworkManager.sendTo(new CPacketDesyncSif(pos), p);
        }
    }
}
项目:CodeChickenLib    文件:PacketCustom.java   
public static void sendToChunk(Packet packet, World world, int chunkX, int chunkZ) {

        PlayerChunkMapEntry playerInstance = ((WorldServer) world).getPlayerChunkMap().getEntry(chunkX, chunkZ);
        if (playerInstance != null) {
            playerInstance.sendPacket(packet);
        }
    }
项目:GriefPrevention    文件:BlockUtils.java   
public static boolean regenerateChunk(Chunk chunk) {
    boolean unload = unloadChunk(chunk);
    ChunkProviderServer chunkProviderServer = (ChunkProviderServer) chunk.getWorld().getChunkProvider();

    Chunk newChunk = chunkProviderServer.chunkGenerator.generateChunk(chunk.x, chunk.z);
    PlayerChunkMapEntry playerChunk = ((WorldServer) chunk.getWorld()).getPlayerChunkMap().getEntry(chunk.x, chunk.z);
    if (playerChunk != null) {
        playerChunk.chunk = newChunk;
    }

    chunkLoadPostProcess(newChunk);
    refreshChunk(newChunk);
    return newChunk != null;
}
项目:OpenModsLib    文件:NetUtils.java   
public static Set<EntityPlayerMP> getPlayersWatchingChunk(WorldServer world, int chunkX, int chunkZ) {
    final PlayerChunkMapEntry playerChunkMap = world.getPlayerChunkMap().getEntry(chunkX, chunkZ);

    final Set<EntityPlayerMP> playerList = Sets.newHashSet();
    if (playerChunkMap == null || !playerChunkMap.isSentToPlayers())
        return playerList;

    for (EntityPlayer o : world.playerEntities) {
        EntityPlayerMP player = (EntityPlayerMP)o;
        if (playerChunkMap.containsPlayer(player)) playerList.add(player);
    }
    return playerList;
}
项目:FastAsyncWorldedit    文件:ForgeQueue_All.java   
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }


    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = chunkServer.chunkGenerator;
        long pos = ChunkPos.chunkXZ2Int(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onChunkUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onChunkUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        chunkServer.id2ChunkMap.remove(pos);
        mcChunk = gen.provideChunk(x, z);
        chunkServer.id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onChunkLoad();
            mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    }
}
项目:FastAsyncWorldedit    文件:SpongeQueue_1_11.java   
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onChunkUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onChunkUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer);
        id2ChunkMap.remove(pos);
        mcChunk = gen.provideChunk(x, z);
        id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onChunkLoad();
            mcChunk.populateChunk(chunkServer, gen);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}
项目:FastAsyncWorldedit    文件:SpongeQueue_1_12.java   
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer);
        id2ChunkMap.remove(pos);
        mcChunk = gen.generateChunk(x, z);
        id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onLoad();
            mcChunk.populate(chunkServer, gen);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}
项目:FastAsyncWorldedit    文件:ForgeQueue_All.java   
public boolean regenerateChunk(World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        Long2ObjectMap<Chunk> id2ChunkMap = chunkServer.id2ChunkMap;
        id2ChunkMap.remove(pos);
        mcChunk = gen.generateChunk(x, z);
        id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onLoad();
            mcChunk.populate(chunkServer, gen);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}
项目:FastAsyncWorldedit    文件:ForgeQueue_All.java   
@Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = chunkServer.chunkGenerator;
        long pos = ChunkPos.chunkXZ2Int(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onChunkUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onChunkUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        chunkServer.id2ChunkMap.remove(pos);
        mcChunk = gen.provideChunk(x, z);
        chunkServer.id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onChunkLoad();
            mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    }
}
项目:FastAsyncWorldedit    文件:ForgeQueue_All.java   
public boolean regenerateChunk(World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = chunkServer.chunkGenerator;
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onChunkUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onChunkUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        chunkServer.id2ChunkMap.remove(pos);
        mcChunk = gen.provideChunk(x, z);
        chunkServer.id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onChunkLoad();
            mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}