CoverContent class

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

Файл: com/hypixel/hytale/builtin/worldgen/modifier/content/cover/CoverContent.java

implements: Content

Поля (7)

МодификаторыТипИмя
final BuilderCodec<CoverContent> CODEC
public static final BuilderCodec<CoverContent.Entry> CODEC
public static final CoverContent.Entry[] EMPTY_ARRAY
protected int offset
WeightedMap.Builder var3
int var8
BlockFluidEntry var9

Методы (3)

МодификаторыВозвратСигнатура
public Entrypublic Entry()
protected <T> IWeightedMap<T> buildEntries<T> IWeightedMap<T> buildEntries(@Nonnull T[] var1, @Nonnull BiFunction<CoverContent.Entry, BlockFluidEntry, T> var2)
for for(CoverContent.Entry var7 : this.entries)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.Content;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.common.BlockEntry;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.common.BlockMask;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.common.HeightMask;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.common.NoiseMask;
class="kw">import com.hypixel.hytale.codec.Codec;
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.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.common.map.IWeightedMap;
class="kw">import com.hypixel.hytale.common.map.WeightedMap;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry;
class="kw">import java.util.function.BiFunction;
class="kw">import javax.annotation.Nonnull;

class="kw">public class="kw">abstract class CoverContent class="kw">implements Content {
   class="kw">public class="kw">static class="kw">final BuilderCodec<CoverContent> CODEC = BuilderCodec.abstractBuilder(CoverContent.class)
      .append(
         new KeyedCodec<>("Entries", new ArrayCodec<>(CoverContent.Entry.CODEC, CoverContent.Entry[]::new)),
         (var0, var1) -> var0.entries = var1,
         var0 -> var0.entries
      )
      .documentation("A list of blocks that can be placed as a cover")
      .add()
      .<NoiseMask>append(new KeyedCodec<>("NoiseMask", NoiseMask.CODEC), (var0, var1) -> var0.noiseMask = var1, var0 -> var0.noiseMask)
      .documentation("A mask used to determine where the cover should be placed based on noise")
      .add()
      .<HeightMask>append(new KeyedCodec<>("HeightMask", HeightMask.CODEC), (var0, var1) -> var0.heightMask = var1, var0 -> var0.heightMask)
      .documentation("A mask used to determine where the cover should be placed based on height")
      .add()
      .<BlockMask>append(new KeyedCodec<>("ParentMask", BlockMask.CODEC), (var0, var1) -> var0.parentMask = var1, var0 -> var0.parentMask)
      .documentation("A mask used to filter which blocks can be covered")
      .add()
      .<Double>append(new KeyedCodec<>("Chance", Codec.DOUBLE), (var0, var1) -> var0.chance = var1, var0 -> var0.chance)
      .addValidator(Validators.range(0.0, 1.0))
      .documentation("The random chance that the cover will be placed at a given position")
      .add()
      .build();
   class="kw">protected CoverContent.Entry[] entries = CoverContent.Entry.EMPTY_ARRAY;
   class="kw">protected NoiseMask noiseMask = NoiseMask.DEFAULT;
   class="kw">protected HeightMask heightMask = HeightMask.DEFAULT;
   class="kw">protected BlockMask parentMask = BlockMask.REPLACE_SOLID;
   class="kw">protected double chance = 1.0;

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

   class="kw">protected <T> IWeightedMap<T> buildEntries(@Nonnull T[] var1, @Nonnull BiFunction<CoverContent.Entry, BlockFluidEntry, T> var2) {
      WeightedMap.Builder var3 = WeightedMap.builder(var1);

      for (CoverContent.Entry var7 : this.entries) {
         int var8 = BlockType.getAssetMap().getIndex(var7.block());
         BlockFluidEntry var9 = new BlockFluidEntry(var8, 0, 0);
         var3.put(var2.apply(var7, var9), var7.weight());
      }

      class="kw">return var3.build();
   }

   class="kw">public class="kw">static class Entry class="kw">extends BlockEntry {
      class="kw">public class="kw">static class="kw">final BuilderCodec<CoverContent.Entry> CODEC = BuilderCodec.builder(CoverContent.Entry.class, CoverContent.Entry::new, BlockEntry.CODEC)
         .documentation("Define a block to be placed as a cover")
         .<Integer>append(new KeyedCodec<>("Offset", Codec.INTEGER), (var0, var1) -> var0.offset = var1, var0 -> var0.offset)
         .documentation("The vertical offset from the surface for this cover entry")
         .add()
         .build();
      class="kw">public class="kw">static class="kw">final CoverContent.Entry[] EMPTY_ARRAY = new CoverContent.Entry[0];
      class="kw">protected int offset = 0;

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