use of net.minecraft.world.gen.ChunkProviderServer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method replaceOuterChunksWithAir.
//Experimental, could fix issues with random shit generating inside of Ships
private void replaceOuterChunksWithAir() {
for (int x = ownedChunks.minX - 1; x <= ownedChunks.maxX + 1; x++) {
for (int z = ownedChunks.minZ - 1; z <= ownedChunks.maxZ + 1; z++) {
if (x == ownedChunks.minX - 1 || x == ownedChunks.maxX + 1 || z == ownedChunks.minZ - 1 || z == ownedChunks.maxZ + 1) {
//This is satisfied for the chunks surrounding a Ship, do fill it with empty space
Chunk chunk = new Chunk(worldObj, x, z);
ChunkProviderServer provider = (ChunkProviderServer) worldObj.getChunkProvider();
chunk.isModified = true;
provider.id2ChunkMap.put(ChunkPos.chunkXZ2Int(x, z), chunk);
}
}
}
}
use of net.minecraft.world.gen.ChunkProviderServer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method injectChunkIntoWorld.
public void injectChunkIntoWorld(Chunk chunk, int x, int z, boolean putInId2ChunkMap) {
ChunkProviderServer provider = (ChunkProviderServer) worldObj.getChunkProvider();
//TileEntities will break if you don't do this
chunk.isChunkLoaded = true;
chunk.isModified = true;
claimedChunks[x - ownedChunks.minX][z - ownedChunks.minZ] = chunk;
if (putInId2ChunkMap) {
provider.id2ChunkMap.put(ChunkPos.chunkXZ2Int(x, z), chunk);
}
PlayerChunkMap map = ((WorldServer) worldObj).getPlayerChunkMap();
PlayerChunkMapEntry entry = new PlayerChunkMapEntry(map, x, z) {
@Override
public boolean hasPlayerMatchingInRange(double range, Predicate<EntityPlayerMP> predicate) {
return true;
}
};
long i = map.getIndex(x, z);
map.playerInstances.put(i, entry);
map.playerInstanceList.add(entry);
entry.sentToPlayers = true;
entry.players = watchingPlayers;
claimedChunksEntries[x - ownedChunks.minX][z - ownedChunks.minZ] = entry;
// MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(chunk));
}
use of net.minecraft.world.gen.ChunkProviderServer in project RFToolsDimensions by McJty.
the class RfToolsDimensionManager method touchSpawnChunk.
private void touchSpawnChunk(World world, int id) {
// Make sure world generation kicks in for at least one chunk so that our matter receiver
// is generated and registered.
WorldServer worldServerForDimension = world.getMinecraftServer().getWorld(id);
ChunkProviderServer providerServer = worldServerForDimension.getChunkProvider();
if (!providerServer.chunkExists(0, 0)) {
try {
providerServer.provideChunk(0, 0);
providerServer.chunkGenerator.populate(0, 0);
} catch (Exception e) {
Logging.logError("Something went wrong during creation of the dimension!");
e.printStackTrace();
// We catch this exception to make sure our dimension tab is at least ok.
}
}
}
use of net.minecraft.world.gen.ChunkProviderServer in project SpongeCommon by SpongePowered.
the class MixinWorldServer method updateWorldGenerator.
@Override
public void updateWorldGenerator() {
// Get the default generator for the world type
DataContainer generatorSettings = this.getProperties().getGeneratorSettings();
SpongeWorldGenerator newGenerator = createWorldGenerator(generatorSettings);
// by the base generation populator
if (newGenerator.getBaseGenerationPopulator() instanceof IChunkGenerator) {
// from a mod chunk provider extending a provider that we mixed into
if (WorldGenConstants.isValid((IChunkGenerator) newGenerator.getBaseGenerationPopulator(), IPopulatorProvider.class)) {
((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
}
} else if (newGenerator.getBaseGenerationPopulator() instanceof IPopulatorProvider) {
// If its not a chunk provider but is a populator provider then we call it as well
((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
}
for (WorldGeneratorModifier modifier : this.getProperties().getGeneratorModifiers()) {
modifier.modifyWorldGenerator(this.getProperties(), generatorSettings, newGenerator);
}
this.spongegen = createChunkGenerator(newGenerator);
this.spongegen.setGenerationPopulators(newGenerator.getGenerationPopulators());
this.spongegen.setPopulators(newGenerator.getPopulators());
this.spongegen.setBiomeOverrides(newGenerator.getBiomeSettings());
ChunkProviderServer chunkProviderServer = this.getChunkProvider();
chunkProviderServer.chunkGenerator = this.spongegen;
}
use of net.minecraft.world.gen.ChunkProviderServer in project SpongeCommon by SpongePowered.
the class MixinWorldServer method doChunkGC.
// Chunk GC
@Override
public void doChunkGC() {
this.chunkGCTickCount++;
ChunkProviderServer chunkProviderServer = this.getChunkProvider();
int chunkLoadCount = this.getChunkProvider().getLoadedChunkCount();
if (chunkLoadCount >= this.chunkGCLoadThreshold && this.chunkGCLoadThreshold > 0) {
chunkLoadCount = 0;
} else if (this.chunkGCTickCount >= this.chunkGCTickInterval && this.chunkGCTickInterval > 0) {
this.chunkGCTickCount = 0;
} else {
return;
}
for (net.minecraft.world.chunk.Chunk chunk : chunkProviderServer.getLoadedChunks()) {
IMixinChunk spongeChunk = (IMixinChunk) chunk;
if (chunk.unloadQueued || spongeChunk.isPersistedChunk() || !this.provider.canDropChunk(chunk.x, chunk.z)) {
continue;
}
// If a player is currently using the chunk, skip it
if (((IMixinPlayerChunkMap) this.getPlayerChunkMap()).isChunkInUse(chunk.x, chunk.z)) {
continue;
}
// If we reach this point the chunk leaked so queue for unload
chunkProviderServer.queueUnload(chunk);
SpongeHooks.logChunkGCQueueUnload(chunkProviderServer.world, chunk);
}
}
Aggregations