Java Code Examples for net.minecraft.world.chunk.Chunk#setTerrainPopulated()
The following examples show how to use
net.minecraft.world.chunk.Chunk#setTerrainPopulated() .
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: 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 2
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); } }