ChunkLightingCommand class

Пакет: com.hypixel.hytale.server.core.command.commands.world.chunk

Файл: com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLightingCommand.java

extends: AbstractWorldCommand

Поля (9)

МодификаторыТипИмя
Ref var10
BlockChunk var11
BlockSection var12
String var13
Vector3i var4
ChunkStore var5
Store var6
Vector2i var7
long var8

Методы (1)

МодификаторыВозвратСигнатура
abstract super super("lighting", "server.commands.chunklighting.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.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
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.RelativeIntPosition;
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.section.BlockSection;
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.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector2i;
class="kw">import org.joml.Vector3i;

class="kw">public class ChunkLightingCommand class="kw">extends AbstractWorldCommand {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_CHUNKINFO_SERIALIZED = Message.translation("server.commands.chunkinfo.serialized");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_CHUNKINFO_SERIALIZED_FAILED = Message.translation("server.commands.chunkinfo.serialized.failed");
   @Nonnull
   class="kw">private class="kw">final RequiredArg<RelativeIntPosition> positionArg = this.withRequiredArg(
      "x y z", "server.commands.chunk.lighting.position.desc", ArgTypes.RELATIVE_BLOCK_POSITION
   );

   class="kw">public ChunkLightingCommand() {
      super("lighting", "server.commands.chunklighting.desc");
   }

   @Override
   class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
      Vector3i var4 = this.positionArg.get(var1).getBlockPosition(var1, var3);
      ChunkStore var5 = var2.getChunkStore();
      Store var6 = var5.getStore();
      Vector2i var7 = new Vector2i(ChunkUtil.chunkCoordinate(var4.x()), ChunkUtil.chunkCoordinate(var4.z()));
      long var8 = ChunkUtil.indexChunk(var7.x, var7.y);
      Ref var10 = var5.getChunkReference(var8);
      if (var10 != null && var10.isValid()) {
         BlockChunk var11 = var6.getComponent(var10, BlockChunk.getComponentType());
         assert var11 != null;

         try {
            BlockSection var12 = var11.getSectionAtBlockY(var4.y);
            String var13 = var12.getLocalLight().octreeToString();
            HytaleLogger.getLogger().at(Level.INFO).log("Chunk light output for (%d, %d, %d): %s", var4.x, var4.y, var4.z, var13);
            var1.sendMessage(MESSAGE_COMMANDS_CHUNKINFO_SERIALIZED);
         } catch (Throwable var14) {
            ((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(var14)).log("Failed to print chunk:");
            var1.sendMessage(MESSAGE_COMMANDS_CHUNKINFO_SERIALIZED_FAILED);
         }
      } else {
         var1.sendMessage(
            Message.translation("server.commands.errors.chunkNotLoaded").param("chunkX", var7.x).param("chunkZ", var7.y).param("world", var2.getName())
         );
         var1.sendMessage(Message.translation("server.commands.chunkinfo.load.usage").param("chunkX", var7.x).param("chunkZ", var7.y));
      }
   }
}