ChunkFixHeightMapCommand class
Пакет: com.hypixel.hytale.server.core.command.commands.world.chunk
Файл: com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkFixHeightMapCommand.java
extends: AbstractWorldCommand
Поля (11)
| Модификаторы | Тип | Имя |
|---|---|---|
|
WorldChunk |
var10 |
|
BlockChunk |
var11 |
|
ScheduledFuture[] |
var13 |
|
int[] |
var14 |
|
RelativeChunkPosition |
var4 |
|
ChunkLightingManager |
var4 |
|
Vector2i |
var5 |
|
ChunkStore |
var5 |
|
Store |
var6 |
|
long |
var7 |
|
Ref |
var9 |
Методы (5)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
void |
fixHeightMapvoid fixHeightMap(@Nonnull CommandContext var0, @Nonnull World var1, int var2, int var3) |
abstract |
|
fixHeightMap fixHeightMap(var1, var2, var5.x, var5.y) |
|
|
for for(int var12 = 0; var12 < 10; var12++) |
|
|
if if(var14[0]++ > 60) |
abstract |
|
super super("fixheight", "server.commands.chunk.fixheight.desc") |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.command.commands.world.chunk;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.server.core.HytaleServer;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeChunkPosition;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.lighting.ChunkLightingManager;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.concurrent.ScheduledFuture;
class="kw">import java.util.concurrent.TimeUnit;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector2i;
class="kw">public class ChunkFixHeightMapCommand class="kw">extends AbstractWorldCommand {
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_STARTED = Message.translation("server.commands.chunk.fixHeightMap.started");
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_DONE = Message.translation("server.commands.chunk.fixHeightMap.done");
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_INVALIDATING_LIGHTING = Message.translation(
"server.commands.chunk.fixHeightMap.invalidatingLighting"
);
@Nonnull
class="kw">private class="kw">final RequiredArg<RelativeChunkPosition> chunkPosArg = this.withRequiredArg(
"x z", "server.commands.chunk.fixheight.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION
);
class="kw">public ChunkFixHeightMapCommand() {
super("fixheight", "server.commands.chunk.fixheight.desc");
}
@Override
class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
RelativeChunkPosition var4 = this.chunkPosArg.get(var1);
Vector2i var5 = var4.getChunkPosition(var1, var3);
fixHeightMap(var1, var2, var5.x, var5.y);
}
class="kw">private class="kw">static void fixHeightMap(@Nonnull CommandContext var0, @Nonnull World var1, int var2, int var3) {
ChunkLightingManager var4 = var1.getChunkLighting();
ChunkStore var5 = var1.getChunkStore();
Store var6 = var5.getStore();
long var7 = ChunkUtil.indexChunk(var2, var3);
Ref var9 = var5.getChunkReference(var7);
if (var9 != null && var9.isValid()) {
WorldChunk var10 = var6.getComponent(var9, WorldChunk.getComponentType());
assert var10 != null;
BlockChunk var11 = var6.getComponent(var9, BlockChunk.getComponentType());
assert var11 != null;
var0.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_STARTED);
var11.updateHeightmap();
var0.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_DONE);
var0.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_INVALIDATING_LIGHTING);
for (int var12 = 0; var12 < 10; var12++) {
var11.getSectionAtIndex(var12).invalidateLocalLight();
}
var4.invalidateLightInChunk(var1.getChunkStore(), var2, var3);
var0.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_DONE);
var0.sendMessage(Message.translation("server.commands.chunk.fixHeightMap.waitingForLighting").param("x", var2).param("z", var3));
int[] var14 = new int[]{0};
ScheduledFuture[] var13 = new ScheduledFuture[1];
var13[0] = HytaleServer.SCHEDULED_EXECUTOR.scheduleWithFixedDelay(() -> {
if (var4.isQueued(var2, var3)) {
if (var14[0]++ > 60) {
var13[0].cancel(false);
var0.sendMessage(Message.translation("server.commands.chunk.fixHeightMap.lightingError").param("x", var2).param("z", var3));
}
} else {
var1.getNotificationHandler().updateChunk(var7);
var0.sendMessage(Message.translation("server.commands.chunk.fixHeightMap.lightingFinished").param("x", var2).param("z", var3));
var13[0].cancel(false);
}
}, 1L, 1L, TimeUnit.SECONDS);
} else {
var0.sendMessage(
Message.translation("server.commands.errors.chunkNotLoaded").param("chunkX", var2).param("chunkZ", var3).param("world", var1.getName())
);
}
}
}