CavePrefabContent class

Пакет: com.hypixel.hytale.builtin.worldgen.modifier.content.prefab

Файл: com/hypixel/hytale/builtin/worldgen/modifier/content/prefab/CavePrefabContent.java

extends: PrefabContent

Поля (1)

МодификаторыТипИмя
final String ID

Методы (5)

МодификаторыВозвратСигнатура
protected CavePrefabContainer.CavePrefabEntry.CavePrefabConfig buildConfigCavePrefabContainer.CavePrefabEntry.CavePrefabConfig buildConfig(@Nonnull SeedString<SeedStringResource> var1)
protected IDoubleCoordinateHashSupplier buildDisplacementModifierIDoubleCoordinateHashSupplier buildDisplacementModifier()
protected IDoubleRange buildIterationsIDoubleRange buildIterations()
if if(this.prefabs.length != 0)
if if(var1 instanceof ModifyEvents.CavePrefabs var2)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.Codecs;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.Content;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.event.ModifyEvent;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.event.ModifyEvents;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.math.range.IntRange;
class="kw">import com.hypixel.hytale.math.util.HashUtil;
class="kw">import com.hypixel.hytale.procedurallib.condition.ConstantIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.procedurallib.supplier.DoubleRange;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleCoordinateHashSupplier;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleRange;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CavePrefabPlacement;
class="kw">import com.hypixel.hytale.server.worldgen.cave.prefab.CavePrefabContainer;
class="kw">import javax.annotation.Nonnull;

class="kw">public class CavePrefabContent class="kw">extends PrefabContent {
   class="kw">public class="kw">static class="kw">final String ID = "CavePrefab";
   class="kw">public class="kw">static class="kw">final BuilderCodec<CavePrefabContent> CODEC = BuilderCodec.builder(CavePrefabContent.class, CavePrefabContent::new, PrefabContent.CODEC)
      .documentation("Define a set of one or more prefabs that should be generated in the target cave(s)")
      .<CavePrefabPlacement>append(
         new KeyedCodec<>("Placement", new EnumCodec<>(CavePrefabPlacement.class)), (var0, var1) -> var0.placement = var1, var0 -> var0.placement
      )
      .documentation("The cave prefab placement mode")
      .add()
      .<IntRange>append(new KeyedCodec<>("Iterations", Codecs.INT_RANGE), (var0, var1) -> var0.iterations = var1, var0 -> var0.iterations)
      .documentation("The iteration range for cave prefab placement")
      .add()
      .build();
   class="kw">protected CavePrefabPlacement placement = CavePrefabPlacement.FLOOR;
   class="kw">protected IntRange iterations = new IntRange(1, 1);

   class="kw">public CavePrefabContent() {
   }

   @Override
   class="kw">public Content.Type type() {
      class="kw">return Content.Type.CAVE_PREFAB;
   }

   @Override
   class="kw">public <T> void applyTo(ModifyEvent<T> var1) class="kw">throws Exception {
      if (this.prefabs.length != 0) {
         if (var1 class="kw">instanceof ModifyEvents.CavePrefabs var2) {
            var2.entries().add(new CavePrefabContainer.CavePrefabEntry(this.buildPrefabs(var1.seed()), this.buildConfig(var1.seed())));
         }
      }
   }

   class="kw">protected CavePrefabContainer.CavePrefabEntry.CavePrefabConfig buildConfig(@Nonnull SeedString<SeedStringResource> var1) {
      class="kw">return new CavePrefabContainer.CavePrefabEntry.CavePrefabConfig(
         this.rotations,
         this.placement,
         ConstantIntCondition.DEFAULT_TRUE,
         this.blockMask.getBlockMask(),
         this.buildIterations(),
         this.buildDisplacementModifier(),
         this.noiseMask.build(var1),
         this.heightMask.getCondition()
      );
   }

   class="kw">protected IDoubleCoordinateHashSupplier buildDisplacementModifier() {
      class="kw">return (var1, var2, var3, var4) -> HashUtil.random(var1, var2, var3, var4) * this.offsetY;
   }

   class="kw">protected IDoubleRange buildIterations() {
      class="kw">return this.iterations.getInclusiveMax() == this.iterations.getInclusiveMin()
         ? new DoubleRange.Constant(this.iterations.getInclusiveMin())
         : new DoubleRange.Normal(this.iterations.getInclusiveMin(), this.iterations.getInclusiveMax());
   }
}