net.minecraft.server.management.PlayerChunkMapEntry Java Examples
The following examples show how to use
net.minecraft.server.management.PlayerChunkMapEntry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImplShipChunkClaims.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
private void injectChunkIntoWorld(int x, int z, Chunk chunk) { ChunkProviderServer provider = (ChunkProviderServer) this.getWorldObj().getChunkProvider(); chunk.dirty = true; // claimedChunks[x - getgetOwnedChunks().getMinX()][z - getgetOwnedChunks().getMinZ()] = chunk; loadedChunksMap.put(ChunkPos.asLong(x, z), chunk); provider.loadedChunks.put(ChunkPos.asLong(x, z), chunk); chunk.onLoad(); PlayerChunkMap map = ((WorldServer) this.getWorldObj()).getPlayerChunkMap(); PlayerChunkMapEntry entry = new PlayerChunkMapEntry(map, x, z); long i = PlayerChunkMap.getIndex(x, z); // TODO: In future we need to do better to account for concurrency. map.entryMap.put(i, entry); map.entries.add(entry); entry.sentToPlayers = true; // TODO: In future we need to do better to account for concurrency. entry.players = Collections.unmodifiableList(shipHolder.getWatchingPlayers()); }
Example #2
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 5 votes |
public boolean regenerateChunk(int x, int z) { if (!unloadChunk0(x, z, false)) { return false; } final long chunkKey = ChunkPos.asLong(x, z); world.getChunkProvider().droppedChunksSet.remove(chunkKey); net.minecraft.world.chunk.Chunk chunk = null; chunk = world.getChunkProvider().chunkGenerator.generateChunk(x, z); PlayerChunkMapEntry playerChunk = world.getPlayerChunkMap().getEntry(x, z); if (playerChunk != null) { playerChunk.chunk = chunk; } if (chunk != null) { world.getChunkProvider().id2ChunkMap.put(chunkKey, chunk); chunk.onLoad(); chunk.populateCB(world.getChunkProvider(), world.getChunkProvider().chunkGenerator, true); refreshChunk(x, z); } return chunk != null; }
Example #3
Source File: ClaimedChunkCacheController.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public void injectChunkIntoWorld(Chunk chunk, int x, int z, boolean putInId2ChunkMap) { VSChunkClaim chunkClaim = parent.getOwnedChunks(); chunk.generateSkylightMap(); chunk.checkLight(); // Make sure this chunk knows we own it. ((IPhysicsChunk) chunk).setParentPhysicsObject(Optional.of(this.parent)); ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); chunk.dirty = true; claimedChunks[x - chunkClaim.minX()][z - chunkClaim.minZ()] = chunk; if (putInId2ChunkMap) { provider.loadedChunks.put(ChunkPos.asLong(x, z), chunk); } chunk.onLoad(); // We need to set these otherwise certain events like Sponge's PhaseTracker will refuse to work properly with ships! chunk.setTerrainPopulated(true); chunk.setLightPopulated(true); // Inject the entry into the player chunk map. // Sanity check first if (!((WorldServer) world).isCallingFromMinecraftThread()) { throw new IllegalThreadStateException("We cannot call this crap from another thread!"); } PlayerChunkMap map = ((WorldServer) world).getPlayerChunkMap(); PlayerChunkMapEntry entry = map.getOrCreateEntry(x, z); entry.sentToPlayers = true; entry.players = parent.getWatchingPlayers(); }
Example #4
Source File: BlockUtils.java From GriefPrevention with MIT License | 5 votes |
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; }
Example #5
Source File: NetUtils.java From OpenModsLib with MIT License | 5 votes |
public static Set<EntityPlayerMP> getPlayersWatchingChunk(WorldServer world, int chunkX, int chunkZ) { final PlayerChunkMapEntry playerChunkMap = world.getPlayerChunkMap().getEntry(chunkX, chunkZ); if (playerChunkMap == null) return ImmutableSet.of(); return ImmutableSet.copyOf(playerChunkMap.getWatchingPlayers()); }
Example #6
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@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; } }
Example #7
Source File: SpongeQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
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; } }
Example #8
Source File: SpongeQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
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; } }
Example #9
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
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; } }
Example #10
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@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; } }
Example #11
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
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; } }