use of net.minecraft.world.server.ServerChunkProvider in project minecolonies by Minecolonies.
the class Colony method updateChunkLoadTimer.
/**
* Check if we can unload the colony now.
* Update chunk unload timer and releases chunks when it hits 0.
*/
private void updateChunkLoadTimer() {
if (getConfig().getServer().forceLoadColony.get()) {
for (final ServerPlayerEntity sub : getPackageManager().getCloseSubscribers()) {
if (getPermissions().hasPermission(sub, Action.CAN_KEEP_COLONY_ACTIVE_WHILE_AWAY)) {
this.forceLoadTimer = CHUNK_UNLOAD_DELAY;
for (final long pending : pendingChunks) {
checkChunkAndRegisterTicket(pending, world.getChunk(ChunkPos.getX(pending), ChunkPos.getZ(pending)));
}
pendingChunks.clear();
return;
}
}
if (this.forceLoadTimer > 0) {
this.forceLoadTimer -= MAX_TICKRATE;
if (this.forceLoadTimer <= 0) {
for (final long chunkPos : this.ticketedChunks) {
final int chunkX = ChunkPos.getX(chunkPos);
final int chunkZ = ChunkPos.getZ(chunkPos);
if (world instanceof ServerWorld) {
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
((ServerChunkProvider) world.getChunkSource()).removeRegionTicket(KEEP_LOADED_TYPE, pos, 2, pos);
}
}
ticketedChunks.clear();
ticketedChunksDirty = true;
}
}
}
}
use of net.minecraft.world.server.ServerChunkProvider in project minecolonies by Minecolonies.
the class CommandUnloadForcedChunks method onExecute.
/**
* What happens when the command is executed
*
* @param context the context of the command execution
*/
@Override
public int onExecute(final CommandContext<CommandSource> context) {
final Entity sender = context.getSource().getEntity();
if (sender instanceof PlayerEntity) {
final World world = sender.level;
for (long chunk : ((ServerChunkProvider) sender.level.getChunkSource()).chunkMap.visibleChunkMap.keySet()) {
((ServerWorld) world).setChunkForced(ChunkPos.getX(chunk), ChunkPos.getZ(chunk), false);
}
sender.sendMessage(new StringTextComponent("Successfully removed forceload flag!"), sender.getUUID());
return 1;
}
return 0;
}
use of net.minecraft.world.server.ServerChunkProvider in project endergetic by team-abnormals.
the class ServerWorldMixin method updateBalloons.
@SuppressWarnings("deprecation")
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;inChunk:Z", ordinal = 1, shift = At.Shift.AFTER), method = "tickNonPassenger")
private void updateBalloons(Entity entity, CallbackInfo info) {
BalloonHolder balloonHolder = (BalloonHolder) entity;
ServerChunkProvider chunkProvider = ((ServerWorld) (Object) this).getChunkSource();
for (BolloomBalloonEntity balloon : balloonHolder.getBalloons()) {
if (!balloon.removed && balloon.getAttachedEntity() == entity) {
if (chunkProvider.isEntityTickingChunk(balloon)) {
balloon.setPosAndOldPos(balloon.getX(), balloon.getY(), balloon.getZ());
balloon.yRotO = balloon.yRot;
balloon.xRotO = balloon.xRot;
if (balloon.inChunk) {
balloon.tickCount++;
balloon.updateAttachedPosition();
}
((ServerWorld) (Object) this).updateChunkPos(balloon);
}
} else {
balloon.detachFromEntity();
}
}
}
use of net.minecraft.world.server.ServerChunkProvider in project dynmap by webbukkit.
the class ForgeMapChunkCache method setChunks.
public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
this.w = (ServerWorld) dw.getWorld();
if (dw.isLoaded()) {
/* Check if world's provider is ServerChunkProvider */
AbstractChunkProvider cp = this.w.getChunkProvider();
if (cp instanceof ServerChunkProvider) {
cps = (ServerChunkProvider) cp;
} else {
Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
}
}
super.setChunks(dw, chunks);
}
use of net.minecraft.world.server.ServerChunkProvider in project Arclight by IzzelAliz.
the class MinecraftServerMixin method loadSpawn.
public void loadSpawn(IChunkStatusListener listener, ServerWorld serverWorld) {
if (!((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
return;
}
this.setUserMessage(new TranslationTextComponent("menu.generatingTerrain"));
this.forceTicks = true;
LOGGER.info("Preparing start region for dimension '{}'/{}", serverWorld.getWorldInfo().getWorldName(), DimensionType.getKey(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType()));
BlockPos pos = serverWorld.getSpawnPoint();
listener.start(new ChunkPos(pos));
ServerChunkProvider chunkProvider = serverWorld.getChunkProvider();
chunkProvider.getLightManager().func_215598_a(500);
this.serverTime = Util.milliTime();
chunkProvider.registerTicket(TicketType.START, new ChunkPos(pos), 11, Unit.INSTANCE);
while (chunkProvider.getLoadedChunksCount() != 441) {
this.executeModerately();
}
this.executeModerately();
DimensionType type = serverWorld.dimension.getType();
ForcedChunksSaveData chunks = serverWorld.getSavedData().get(ForcedChunksSaveData::new, "chunks");
if (chunks != null) {
ServerWorld world = this.getWorld(type);
LongIterator iterator = chunks.getChunks().iterator();
while (iterator.hasNext()) {
long i = iterator.nextLong();
ChunkPos chunkPos = new ChunkPos(i);
world.getChunkProvider().forceChunk(chunkPos, true);
}
}
this.executeModerately();
listener.stop();
chunkProvider.getLightManager().func_215598_a(5);
this.forceTicks = false;
}
Aggregations