Constants interface

Пакет: com.hypixel.hytale.server.worldgen.loader.prefab.unique

Файл: com/hypixel/hytale/server/worldgen/loader/prefab/unique/UniquePrefabConfigurationJsonLoader.java

Поля (26)

МодификаторыТипИмя
double DEFAULT_EXCLUSION_RADIUS
int DEFAULT_MAX_ATTEMPTS
double DEFAULT_MAX_DISTANCE
Boolean DEFAULT_SUBMERGE
double DEFAULT_ZONE_BORDER_EXCLUSION
String ERROR_BIOME_ERROR_MASK
String ERROR_LOADING_ENVIRONMENT
String ERROR_NO_ANCHOR
String KEY_ANCHOR
String KEY_BIOME_MASK
String KEY_BORDER_EXCLUSION
String KEY_ENVIRONMENT
String KEY_EXCLUSION_RADIUS
String KEY_FIT_HEIGHTMAP
String KEY_HEIGHT_THRESHOLD
String KEY_IS_SPAWN
String KEY_MASK
String KEY_MAX_ATTEMPTS
String KEY_MAX_DISTANCE
String KEY_NOISE_MASK
String KEY_ON_WATER
String KEY_PARENT
String KEY_SHOW_ON_MAP
String KEY_SPAWN_OFFSET
String KEY_SUBMERGE
String SEED_STRING_BIOME_MASK_TYPE

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.loader.prefab.unique;

class="kw">import com.google.gson.JsonElement;
class="kw">import com.google.gson.JsonObject;
class="kw">import com.hypixel.hytale.procedurallib.condition.ConstantBlockFluidCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ConstantIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.HeightCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IBlockFluidCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ICoordinateCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.ICoordinateRndCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.json.HeightThresholdInterpreterJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.JsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.NoiseMaskConditionJsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
class="kw">import com.hypixel.hytale.server.core.prefab.PrefabRotation;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.loader.biome.BiomeMaskJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.ZoneFileContext;
class="kw">import com.hypixel.hytale.server.worldgen.loader.prefab.BlockPlacementMaskJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.loader.prefab.PrefabPatternGeneratorJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.loader.util.ResolvedBlockArrayJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.loader.util.Vector2dJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.loader.util.Vector3dJsonLoader;
class="kw">import com.hypixel.hytale.server.worldgen.prefab.unique.UniquePrefabConfiguration;
class="kw">import com.hypixel.hytale.server.worldgen.util.ResolvedBlockArray;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.BlockMaskCondition;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.HashSetBlockFluidCondition;
class="kw">import it.unimi.dsi.fastutil.longs.LongSet;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector2d;
class="kw">import org.joml.Vector3d;

class="kw">public class UniquePrefabConfigurationJsonLoader class="kw">extends JsonLoader<SeedStringResource, UniquePrefabConfiguration> {
   class="kw">protected class="kw">final ZoneFileContext zoneContext;

   class="kw">public UniquePrefabConfigurationJsonLoader(SeedString<SeedStringResource> var1, Path var2, JsonElement var3, ZoneFileContext var4) {
      super(var1, var2, var3);
      this.zoneContext = var4;
   }

   @Nonnull
   class="kw">public UniquePrefabConfiguration load() {
      class="kw">return new UniquePrefabConfiguration(
         this.loadHeightThresholds(),
         this.loadMask(),
         this.loadRotations(),
         this.loadBiomeMask(),
         this.loadMapCondition(),
         this.loadParent(),
         this.loadAnchor(),
         this.loadSpawnOffset(),
         this.loadMaxDistance(),
         this.loadFitHeightmap(),
         this.loadSubmerge(),
         this.loadOnWater(),
         this.loadEnvironment(),
         this.loadMaxAttempts(),
         this.loadExclusionRadius(),
         this.loadIsSpawn(),
         this.loadZoneBorderExclusion(),
         this.loadShowOnMap()
      );
   }

   @Nonnull
   class="kw">protected IBlockFluidCondition loadParent() {
      IBlockFluidCondition var1 = ConstantBlockFluidCondition.DEFAULT_TRUE;
      if (this.has("Parent")) {
         ResolvedBlockArray var2 = new ResolvedBlockArrayJsonLoader(this.seed, this.dataFolder, this.get("Parent")).load();
         LongSet var3 = var2.getEntrySet();
         var1 = new HashSetBlockFluidCondition(var3);
      }

      class="kw">return var1;
   }

   @Nullable
   class="kw">protected ICoordinateRndCondition loadHeightThresholds() {
      ICoordinateRndCondition var1 = null;
      if (this.has("HeightThreshold")) {
         JsonObject var2 = this.get("HeightThreshold").getAsJsonObject();
         var1 = new HeightCondition(new HeightThresholdInterpreterJsonLoader<>(this.seed, this.dataFolder, var2, 320).load());
      }

      class="kw">return var1;
   }

   @Nullable
   class="kw">protected IIntCondition loadBiomeMask() {
      IIntCondition var1 = ConstantIntCondition.DEFAULT_TRUE;
      if (this.has("BiomeMask")) {
         var1 = new BiomeMaskJsonLoader(this.seed, this.dataFolder, this.get("BiomeMask"), "UniquePrefab", this.zoneContext).load();
      }

      class="kw">return var1;
   }

   @Nullable
   class="kw">protected PrefabRotation[] loadRotations() {
      PrefabRotation[] var1 = null;
      if (this.has("Rotations")) {
         var1 = PrefabPatternGeneratorJsonLoader.loadRotations(this.get("Rotations"));
      }

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected ICoordinateCondition loadMapCondition() {
      class="kw">return new NoiseMaskConditionJsonLoader<>(this.seed, this.dataFolder, this.get("NoiseMask")).load();
   }

   @Nullable
   class="kw">protected BlockMaskCondition loadMask() {
      BlockMaskCondition var1 = BlockMaskCondition.DEFAULT_TRUE;
      if (this.has("Mask")) {
         var1 = new BlockPlacementMaskJsonLoader(this.seed, this.dataFolder, this.getRaw("Mask")).load();
      }

      class="kw">return var1;
   }

   @Nonnull
   class="kw">protected Vector2d loadAnchor() {
      if (!this.has("Anchor")) {
         throw new IllegalArgumentException("Could not find anchor for Unique prefab generator");
      } else {
         class="kw">return new Vector2dJsonLoader(this.seed, this.dataFolder, this.get("Anchor")).load();
      }
   }

   @Nonnull
   class="kw">protected Vector3d loadSpawnOffset() {
      Vector3d var1 = new Vector3d(0.0, -5000.0, 0.0);
      if (this.has("SpawnOffset")) {
         var1 = new Vector3dJsonLoader(this.seed, this.dataFolder, this.get("SpawnOffset")).load();
      }

      class="kw">return var1;
   }

   class="kw">protected int loadEnvironment() {
      int var1 = Integer.MIN_VALUE;
      if (this.has("Environment")) {
         String var2 = this.get("Environment").getAsString();
         var1 = Environment.getAssetMap().getIndex(var2);
         if (var1 == Integer.MIN_VALUE) {
            throw new Error(String.format("Error while looking up environment \"%s\"!", var2));
         }
      }

      class="kw">return var1;
   }

   class="kw">protected boolean loadFitHeightmap() {
      class="kw">return this.has("FitHeightmap") && this.get("FitHeightmap").getAsBoolean();
   }

   class="kw">protected boolean loadSubmerge() {
      class="kw">return this.mustGetBool("Submerge", UniquePrefabConfigurationJsonLoader.Constants.DEFAULT_SUBMERGE);
   }

   class="kw">protected boolean loadOnWater() {
      class="kw">return this.has("OnWater") && this.get("OnWater").getAsBoolean();
   }

   class="kw">protected double loadMaxDistance() {
      class="kw">return this.has("MaxDistance") ? this.get("MaxDistance").getAsDouble() : 100.0;
   }

   class="kw">protected int loadMaxAttempts() {
      class="kw">return this.has("MaxAttempts") ? this.get("MaxAttempts").getAsInt() : 5000;
   }

   class="kw">protected double loadExclusionRadius() {
      class="kw">return this.has("ExclusionRadius") ? this.get("ExclusionRadius").getAsDouble() : 50.0;
   }

   class="kw">protected boolean loadIsSpawn() {
      class="kw">return this.has("IsSpawn") && this.get("IsSpawn").getAsBoolean();
   }

   class="kw">protected double loadZoneBorderExclusion() {
      class="kw">return this.has("BorderExclusion") ? this.get("BorderExclusion").getAsDouble() : 25.0;
   }

   class="kw">protected boolean loadShowOnMap() {
      class="kw">return this.has("ShowOnMap") && this.get("ShowOnMap").getAsBoolean();
   }

   class="kw">public class="kw">interface Constants {
      String KEY_PARENT = "Parent";
      String KEY_HEIGHT_THRESHOLD = "HeightThreshold";
      String KEY_BIOME_MASK = "BiomeMask";
      String KEY_NOISE_MASK = "NoiseMask";
      String KEY_MASK = "Mask";
      String KEY_ANCHOR = "Anchor";
      String KEY_FIT_HEIGHTMAP = "FitHeightmap";
      String KEY_SUBMERGE = "Submerge";
      String KEY_ENVIRONMENT = "Environment";
      String KEY_ON_WATER = "OnWater";
      String KEY_MAX_DISTANCE = "MaxDistance";
      String KEY_MAX_ATTEMPTS = "MaxAttempts";
      String KEY_EXCLUSION_RADIUS = "ExclusionRadius";
      String KEY_IS_SPAWN = "IsSpawn";
      String KEY_SPAWN_OFFSET = "SpawnOffset";
      String KEY_BORDER_EXCLUSION = "BorderExclusion";
      String KEY_SHOW_ON_MAP = "ShowOnMap";
      String SEED_STRING_BIOME_MASK_TYPE = "UniquePrefab";
      String ERROR_BIOME_ERROR_MASK = "Could not find tile / custom biome \"%s\" for biome mask. Typo or disabled biome?";
      String ERROR_NO_ANCHOR = "Could not find anchor for Unique prefab generator";
      String ERROR_LOADING_ENVIRONMENT = "Error while looking up environment \"%s\"!";
      double DEFAULT_MAX_DISTANCE = 100.0;
      int DEFAULT_MAX_ATTEMPTS = 5000;
      double DEFAULT_EXCLUSION_RADIUS = 50.0;
      double DEFAULT_ZONE_BORDER_EXCLUSION = 25.0;
      Boolean DEFAULT_SUBMERGE = Boolean.FALSE;
   }
}