use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class MixinMinecraftServer method prepareSpawnArea.
@Override
public void prepareSpawnArea(WorldServer worldServer) {
if (!((WorldProperties) worldServer.getWorldInfo()).doesGenerateSpawnOnLoad()) {
return;
}
IMixinChunkProviderServer chunkProviderServer = (IMixinChunkProviderServer) worldServer.getChunkProvider();
chunkProviderServer.setForceChunkRequests(true);
final PhaseTracker phaseTracker = PhaseTracker.getInstance();
try (GenerationContext context = GenerationPhase.State.TERRAIN_GENERATION.createPhaseContext().source(worldServer).world(worldServer).buildAndSwitch()) {
int i = 0;
this.setUserMessage("menu.generatingTerrain");
LOGGER.info("Preparing start region for level {} ({})", ((IMixinWorldServer) worldServer).getDimensionId(), ((World) worldServer).getName());
BlockPos blockpos = worldServer.getSpawnPoint();
long j = MinecraftServer.getCurrentTimeMillis();
for (int k = -192; k <= 192 && this.isServerRunning(); k += 16) {
for (int l = -192; l <= 192 && this.isServerRunning(); l += 16) {
long i1 = MinecraftServer.getCurrentTimeMillis();
if (i1 - j > 1000L) {
this.outputPercentRemaining("Preparing spawn area", i * 100 / 625);
j = i1;
}
++i;
worldServer.getChunkProvider().provideChunk(blockpos.getX() + k >> 4, blockpos.getZ() + l >> 4);
}
}
this.clearCurrentTask();
}
chunkProviderServer.setForceChunkRequests(false);
}
use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class DamageEventHandler method findFirstMatchingBlock.
public static Location<World> findFirstMatchingBlock(Entity entity, AxisAlignedBB bb, Predicate<IBlockState> predicate) {
int i = MathHelper.floor(bb.minX);
int j = MathHelper.floor(bb.maxX + 1.0D);
int k = MathHelper.floor(bb.minY);
int l = MathHelper.floor(bb.maxY + 1.0D);
int i1 = MathHelper.floor(bb.minZ);
int j1 = MathHelper.floor(bb.maxZ + 1.0D);
final IMixinChunkProviderServer spongeChunkProvider = (IMixinChunkProviderServer) entity.world.getChunkProvider();
for (int k1 = i; k1 < j; ++k1) {
for (int l1 = k; l1 < l; ++l1) {
for (int i2 = i1; i2 < j1; ++i2) {
BlockPos blockPos = new BlockPos(k1, l1, i2);
final Chunk chunk = spongeChunkProvider.getLoadedChunkWithoutMarkingActive(blockPos.getX() >> 4, blockPos.getZ() >> 4);
if (chunk == null) {
continue;
}
if (predicate.test(chunk.getBlockState(blockPos))) {
return new Location<>((World) entity.world, k1, l1, i2);
}
}
}
}
// Entity is source of fire
return ((org.spongepowered.api.entity.Entity) entity).getLocation();
}
use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class MixinMapGenStructure method generateStructure.
/**
* @author blood - October 22nd, 2016
* @reason Prevents CME's by avoiding recursive calls while generating structures
*
* @param worldIn The world
* @param randomIn The rand
* @Param chunkCoord The chunk position
* @return true if generation was successful
*/
@Overwrite
public synchronized boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) {
if (generatingStructures) {
return false;
}
Chunk chunk = ((IMixinChunkProviderServer) worldIn.getChunkProvider()).getLoadedChunkWithoutMarkingActive(chunkCoord.x, chunkCoord.z);
if (chunk == null) {
return false;
}
this.initializeStructureData(worldIn);
int i = (chunkCoord.x << 4) + 8;
int j = (chunkCoord.z << 4) + 8;
boolean flag = false;
generatingStructures = true;
for (StructureStart structurestart : this.structureMap.values()) {
if (structurestart.isSizeableStructure() && structurestart.isValidForPostProcess(chunkCoord) && structurestart.getBoundingBox().intersectsWith(i, j, i + 15, j + 15)) {
structurestart.generateStructure(worldIn, randomIn, new StructureBoundingBox(i, j, i + 15, j + 15));
structurestart.notifyPostProcessAt(chunkCoord);
flag = true;
this.setStructureStart(structurestart.getChunkPosX(), structurestart.getChunkPosZ(), structurestart);
}
}
generatingStructures = false;
return flag;
}
use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class EntityActivationRange method activateEntities.
/**
* Find what entities are in range of the players in the world and set
* active if in range.
*
* @param world The world to perform activation checks in
*/
public static void activateEntities(World world) {
if (((IMixinWorld) world).isFake()) {
return;
}
for (EntityPlayer player : world.playerEntities) {
int maxRange = 0;
for (Integer range : maxActivationRanges.values()) {
if (range > maxRange) {
maxRange = range;
}
}
maxRange = Math.min((((org.spongepowered.api.world.World) world).getViewDistance() << 4) - 8, maxRange);
((IModData_Activation) player).setActivatedTick(SpongeImpl.getServer().getTickCounter());
growBb(maxBB, player.getEntityBoundingBox(), maxRange, 256, maxRange);
int i = MathHelper.floor(maxBB.minX / 16.0D);
int j = MathHelper.floor(maxBB.maxX / 16.0D);
int k = MathHelper.floor(maxBB.minZ / 16.0D);
int l = MathHelper.floor(maxBB.maxZ / 16.0D);
for (int i1 = i; i1 <= j; ++i1) {
for (int j1 = k; j1 <= l; ++j1) {
WorldServer worldserver = (WorldServer) world;
Chunk chunk = ((IMixinChunkProviderServer) worldserver.getChunkProvider()).getLoadedChunkWithoutMarkingActive(i1, j1);
if (chunk != null) {
activateChunkEntities(player, chunk);
}
}
}
}
}
use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class MixinWorld_Tracker method setNotifier.
@Override
public void setNotifier(int x, int y, int z, @Nullable UUID uuid) {
final Chunk chunk = ((IMixinChunkProviderServer) this.chunkProvider).getLoadedChunkWithoutMarkingActive(x >> 4, z >> 4);
if (chunk == null) {
return;
}
BlockPos pos = new BlockPos(x, y, z);
((IMixinChunk) chunk).setBlockNotifier(pos, uuid);
}
Aggregations