net.minecraft.world.gen.ChunkProviderServer Java Examples
The following examples show how to use
net.minecraft.world.gen.ChunkProviderServer.
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: WorldEditor.java From minecraft-roguelike with GNU General Public License v3.0 | 6 votes |
@Override public Coord findNearestStructure(VanillaStructure type, Coord pos) { ChunkProviderServer chunkProvider = ((WorldServer)world).getChunkProvider(); String structureName = VanillaStructure.getName(type); BlockPos structurebp = null; try{ structurebp = chunkProvider.getNearestStructurePos(world, structureName, pos.getBlockPos(), false); } catch(NullPointerException e){ // happens for some reason if structure type is disabled in Chunk Generator Settings } if(structurebp == null) return null; return new Coord(structurebp); }
Example #2
Source File: CauldronHooks.java From Thermos with GNU General Public License v3.0 | 6 votes |
private static void logLoadOnRequest(ChunkProviderServer provider, int x, int z) { long currentTick = MinecraftServer.getServer().getTickCounter(); long lastAccessed = provider.lastAccessed(x, z); long diff = currentTick - lastAccessed; logInfo(" Last accessed: {0, number} Current Tick: {1, number} [{2, number}]", lastAccessed, currentTick, diff); logInfo(" Finding Spawn Point: {0}", provider.worldObj.findingSpawnPoint); logInfo(" Load chunk on request: {0}", provider.loadChunkOnProvideRequest); logInfo(" Calling Forge Tick: {0}", MinecraftServer.callingForgeTick); logInfo(" Load chunk on forge tick: {0}", MinecraftServer.cauldronConfig.loadChunkOnForgeTick.getValue()); long providerTickDiff = currentTick - provider.initialTick; if (providerTickDiff <= 100) { logInfo(" Current Tick - Initial Tick: {0, number}", providerTickDiff); } }
Example #3
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 #4
Source File: BlockUtils.java From GriefPrevention with MIT License | 6 votes |
private static void saveChunkData(ChunkProviderServer chunkProviderServer, Chunk chunkIn) { try { chunkIn.setLastSaveTime(chunkIn.getWorld().getTotalWorldTime()); chunkProviderServer.chunkLoader.saveChunk(chunkIn.getWorld(), chunkIn); } catch (IOException ioexception) { //LOGGER.error((String)"Couldn\'t save chunk", (Throwable)ioexception); } catch (MinecraftException minecraftexception) { //LOGGER.error((String)"Couldn\'t save chunk; already in use by another instance of Minecraft?", (Throwable)minecraftexception); } try { chunkProviderServer.chunkLoader.saveExtraChunkData(chunkIn.getWorld(), chunkIn); } catch (Exception exception) { //LOGGER.error((String)"Couldn\'t save entities", (Throwable)exception); } }
Example #5
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #6
Source File: SpongeQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #7
Source File: GT_TileEntity_VoidMiner_Base.java From bartworks with MIT License | 5 votes |
private ModDimensionDef makeModDimDef() { return getModContainers().stream() .flatMap(modContainer -> modContainer.getDimensionList().stream()) .filter(modDimensionDef -> modDimensionDef.getChunkProviderName() .equals(((ChunkProviderServer) this.getBaseMetaTileEntity().getWorld().getChunkProvider()).currentChunkProvider.getClass().getName())) .findFirst().orElse(null); }
Example #8
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.originalLoadChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #9
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) { Chunk chunk = ((ChunkProviderServer)world.getChunkProvider()).id2ChunkMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz)); if (chunk != null) { return chunk.getBlockStorageArray(); } return null; }
Example #10
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 #11
Source File: SpongeQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #12
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #13
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.originalLoadChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #14
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) { Chunk chunk = (Chunk) ((ChunkProviderServer)world.getChunkProvider()).loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz)); if (chunk != null) { return chunk.getBlockStorageArray(); } return null; }
Example #15
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #16
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #17
Source File: WorldRetrogen.java From simpleretrogen with GNU General Public License v3.0 | 5 votes |
private void runRetrogen(WorldServer world, ChunkPos chunkCoords, String retroClass) { long worldSeed = world.getSeed(); Random fmlRandom = new Random(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; long chunkSeed = (xSeed * chunkCoords.chunkXPos + zSeed * chunkCoords.chunkZPos) ^ worldSeed; fmlRandom.setSeed(chunkSeed); ChunkProviderServer providerServer = world.getChunkProvider(); IChunkGenerator generator = ObfuscationReflectionHelper.getPrivateValue(ChunkProviderServer.class, providerServer, "field_186029_c", "chunkGenerator"); delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.chunkXPos, chunkCoords.chunkZPos, world, generator, providerServer); FMLLog.fine("Retrogenerated chunk for %s", retroClass); completeRetrogen(chunkCoords, world, retroClass); }
Example #18
Source File: StructureRegistry.java From OpenModsLib with MIT License | 5 votes |
private void visitStructures(WorldServer world, IStructureVisitor visitor) { ChunkProviderServer provider = world.getChunkProvider(); IChunkGenerator inner = provider.chunkGenerator; if (inner != null) { for (IStructureGenProvider<?> p : providers) tryVisit(visitor, inner, p); } }
Example #19
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 5 votes |
public void processChunkGC() { chunkGCTickCount++; if (chunkLoadCount >= server.chunkGCLoadThresh && server.chunkGCLoadThresh > 0) { chunkLoadCount = 0; } else if (chunkGCTickCount >= server.chunkGCPeriod && server.chunkGCPeriod > 0) { chunkGCTickCount = 0; } else { return; } ChunkProviderServer cps = world.getChunkProvider(); for (net.minecraft.world.chunk.Chunk chunk : cps.id2ChunkMap.values()) { // If in use, skip it if (isChunkInUse(chunk.x, chunk.z)) { continue; } // Already unloading? if (cps.droppedChunksSet.contains(ChunkPos.asLong(chunk.x, chunk.z))) { continue; } // Add unload request cps.queueUnload(chunk); } }
Example #20
Source File: QueuedChunk.java From Kettle with GNU General Public License v3.0 | 5 votes |
public QueuedChunk(int x, int z, AnvilChunkLoader loader, World world, ChunkProviderServer provider) { this.x = x; this.z = z; this.loader = loader; this.world = world; this.provider = provider; }
Example #21
Source File: CauldronHooks.java From Thermos with GNU General Public License v3.0 | 5 votes |
public static void logChunkUnload(ChunkProviderServer provider, int x, int z, String msg) { if (MinecraftServer.cauldronConfig.chunkUnloadLogging.getValue()) { logInfo("{0} [{1}] ({2}, {3})", msg, provider.worldObj.provider.dimensionId, x, z); long currentTick = MinecraftServer.getServer().getTickCounter(); long lastAccessed = provider.lastAccessed(x, z); long diff = currentTick - lastAccessed; logInfo(" Last accessed: {0, number} Current Tick: {1, number} [{2, number}]", lastAccessed, currentTick, diff); } }
Example #22
Source File: CauldronHooks.java From Thermos with GNU General Public License v3.0 | 5 votes |
public static void logChunkLoad(ChunkProviderServer provider, String msg, int x, int z, boolean logLoadOnRequest) { if (MinecraftServer.cauldronConfig.chunkLoadLogging.getValue()) { logInfo("{0} Chunk At [{1}] ({2}, {3})", msg, provider.worldObj.provider.dimensionId, x, z); if (logLoadOnRequest) { logLoadOnRequest(provider, x, z); } logStack(); } }
Example #23
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 #24
Source File: BlockUtils.java From GriefPrevention with MIT License | 5 votes |
private static boolean unloadChunk(net.minecraft.world.chunk.Chunk chunk) { net.minecraft.world.World mcWorld = chunk.getWorld(); ChunkProviderServer chunkProviderServer = (ChunkProviderServer) chunk.getWorld().getChunkProvider(); boolean saveChunk = false; if (chunk.needsSaving(true)) { saveChunk = true; } for (ClassInheritanceMultiMap<Entity> classinheritancemultimap : chunk.getEntityLists()) { chunk.getWorld().unloadEntities(classinheritancemultimap); } if (saveChunk) { saveChunkData(chunkProviderServer, chunk); } chunkProviderServer.id2ChunkMap.remove(ChunkPos.asLong(chunk.x, chunk.z)); ((ChunkBridge) chunk).bridge$setScheduledForUnload(-1); org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) chunk; for (Direction direction : CARDINAL_SET) { Vector3i neighborPosition = spongeChunk.getPosition().add(direction.asBlockOffset()); ChunkProviderBridge spongeChunkProvider = (ChunkProviderBridge) mcWorld.getChunkProvider(); net.minecraft.world.chunk.Chunk neighbor = spongeChunkProvider.bridge$getLoadedChunkWithoutMarkingActive(neighborPosition.getX(), neighborPosition.getZ()); if (neighbor != null) { int neighborIndex = directionToIndex(direction); int oppositeNeighborIndex = directionToIndex(direction.getOpposite()); ((ChunkBridge) spongeChunk).bridge$setNeighborChunk(neighborIndex, null); ((ChunkBridge) neighbor).bridge$setNeighborChunk(oppositeNeighborIndex, null); } } return true; }
Example #25
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 #26
Source File: PhysicsObject.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public void unloadShipChunksFromWorld() { ChunkProviderServer provider = (ChunkProviderServer) world().getChunkProvider(); for (int x = getOwnedChunks().minX(); x <= getOwnedChunks().maxX(); x++) { for (int z = getOwnedChunks().minZ(); z <= getOwnedChunks().maxZ(); z++) { provider.queueUnload(claimedChunkCache.getChunkAt(x, z)); } } }
Example #27
Source File: PhysicsParticleManager.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
private boolean canParticlePassThrough(World world, BlockPos pos) { ChunkProviderServer serverProvider = (ChunkProviderServer) world.getChunkProvider(); // If the chunk isn't loaded, then no problem ignore it. long chunkKey = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4); if (!serverProvider.loadedChunks.containsKey(chunkKey)) { this.isParticleDead = true; return true; } IBlockState collisionState = serverProvider.loadedChunks.get(chunkKey) .getBlockState(pos); // Otherwise we have to bypass the world blockstate get because sponge has some protection on it. // System.out.println("oof"); return collisionState.getBlock().isPassable(world, pos); }
Example #28
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 #29
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); } }
Example #30
Source File: ChunkIOExecutor.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static Chunk syncChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z) { return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider)); }