Java Code Examples for net.minecraft.world.chunk.Chunk#onChunkLoad()
The following examples show how to use
net.minecraft.world.chunk.Chunk#onChunkLoad() .
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: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 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; } ChunkProviderServer chunkServer = (ChunkProviderServer) provider; IChunkProvider chunkProvider = chunkServer.serverChunkGenerator; long pos = ChunkCoordIntPair.chunkXZ2Int(x, z); Chunk mcChunk; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); 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 = chunkProvider.provideChunk(x, z); chunkServer.id2ChunkMap.add(pos, mcChunk); chunkServer.loadedChunks.add(mcChunk); if (mcChunk != null) { mcChunk.onChunkLoad(); mcChunk.populateChunk(chunkProvider, chunkProvider, x, z); } return true; }
Example 2
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void run(IntegerPair loc) { Chunk chunk = getWorld().getChunkProvider().provideChunk(loc.x, loc.z); if (chunk != null && !chunk.isChunkLoaded) { chunk.onChunkLoad(); } }
Example 3
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 4
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 5
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 6
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; } }
Example 7
Source File: RegenChunkCommand.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) { EntityPlayerMP player; try { player = getCommandSenderAsPlayer(sender); } catch (PlayerNotFoundException e) { return; } if(!player.isCreative()) return; WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension()); if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 1) { int radius = Integer.parseInt(params[0]); for(int i = -radius; i <= radius; i++) { for(int k = -radius; k <= radius; k++) { int x = (((int)player.posX+i*16) >> 4); int z = (((int)player.posZ+k*16) >> 4); ChunkProviderServer cps = world.getChunkProvider(); Chunk c = cps.chunkGenerator.provideChunk(x, z); Chunk old = world.getChunkProvider().provideChunk(x, z); old.setStorageArrays(c.getBlockStorageArray()); c.setTerrainPopulated(false); c.onChunkLoad(); c.setChunkModified(); c.checkLight(); cps.chunkGenerator.populate(c.xPosition, c.zPosition); net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider()); c.setChunkModified(); player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff)); } } /*for(int i = -radius; i <= radius; i++) { for(int k = -radius; k <= radius; k++) { int x = (((int)player.posX+i*16) >> 4); int z = (((int)player.posZ+k*16) >> 4); ChunkProviderServer cps = world.getChunkProvider(); Chunk c = cps.chunkGenerator.provideChunk(x, z); Chunk old = world.getChunkProvider().provideChunk(x, z); old.populateChunk(cps, cps.chunkGenerator); if (c.isTerrainPopulated()) { if (cps.chunkGenerator.generateStructures(c, c.xPosition, c.zPosition)) { c.setChunkModified(); } } else { c.checkLight(); cps.chunkGenerator.populate(c.xPosition, c.zPosition); net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider()); c.setChunkModified(); } player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff)); } }*/ } else if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 2 && params[1].equalsIgnoreCase("hex")) { execute(server, sender, new String[] {params[0]}); IslandMap map = Core.getMapForWorld(world, player.getPosition()); HexGenRegistry.generate(Core.getMapForWorld(world, player.getPosition()), map.getClosestCenter(player.getPosition()), world); } }