Entry class
Пакет: com.hypixel.hytale.builtin.worldgen.modifier.content.tint
Файл: com/hypixel/hytale/builtin/worldgen/modifier/content/tint/BiomeTintContent.java
Поля (5)
| Модификаторы | Тип | Имя |
|---|---|---|
|
public static final BuilderCodec<BiomeTintContent.Entry> |
CODEC |
|
protected static final Color |
DEFAULT_COLOR |
|
public static final BiomeTintContent.Entry[] |
EMPTY_ARRAY |
|
protected Color |
color |
|
protected double |
weight |
Методы (1)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public Integer |
colorpublic Integer color() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.worldgen.modifier.content.tint;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.Content;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.common.NoiseMask;
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.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.common.util.ArrayUtil;
class="kw">import com.hypixel.hytale.protocol.Color;
class="kw">import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
class="kw">import com.hypixel.hytale.server.core.codec.ProtocolCodecs;
class="kw">import com.hypixel.hytale.server.worldgen.container.TintContainer;
class="kw">public class BiomeTintContent class="kw">implements Content {
class="kw">public class="kw">static class="kw">final String ID = "BiomeTint";
class="kw">public class="kw">static class="kw">final BuilderCodec<BiomeTintContent> CODEC = BuilderCodec.builder(BiomeTintContent.class, BiomeTintContent::new)
.documentation("Define a set of tints that should be applied to parts of the biome")
.<BiomeTintContent.Entry[]>append(
new KeyedCodec<>("Entries", new ArrayCodec<>(BiomeTintContent.Entry.CODEC, BiomeTintContent.Entry[]::new)),
(var0, var1) -> var0.entries = var1,
var0 -> var0.entries
)
.documentation("The list of weighted colors that will be selected from in order to tint parts of the world")
.add()
.<NoiseMask>append(new KeyedCodec<>("Noise", NoiseMask.CODEC), (var0, var1) -> var0.noise = var1, var0 -> var0.noise)
.documentation("The noise used to select a random tint from the entries list")
.add()
.<NoiseMask>append(new KeyedCodec<>("NoiseMask", NoiseMask.CODEC), (var0, var1) -> var0.noiseMask = var1, var0 -> var0.noiseMask)
.documentation("The noise mask determining where the tint should be applied in the world")
.add()
.build();
class="kw">protected BiomeTintContent.Entry[] entries = BiomeTintContent.Entry.EMPTY_ARRAY;
class="kw">protected NoiseMask noise = NoiseMask.DEFAULT;
class="kw">protected NoiseMask noiseMask = NoiseMask.DEFAULT;
class="kw">public BiomeTintContent() {
}
@Override
class="kw">public Content.Type type() {
class="kw">return Content.Type.BIOME_TINT;
}
@Override
class="kw">public <T> void applyTo(ModifyEvent<T> var1) class="kw">throws Exception {
if (this.entries.length != 0) {
if (var1 class="kw">instanceof ModifyEvents.BiomeTints var2) {
var2.entries().add(new TintContainer.TintContainerEntry(this.buildColors(), this.noise.buildNoise(var1.seed()), this.noiseMask.build(var1.seed())));
}
}
}
class="kw">protected IWeightedMap<Integer> buildColors() {
WeightedMap.Builder var1 = WeightedMap.builder(ArrayUtil.EMPTY_INTEGER_ARRAY);
for (BiomeTintContent.Entry var5 : this.entries) {
var1.put(var5.color(), var5.weight);
}
class="kw">return var1.build();
}
class="kw">public class="kw">static class Entry {
class="kw">public class="kw">static class="kw">final BuilderCodec<BiomeTintContent.Entry> CODEC = BuilderCodec.builder(BiomeTintContent.Entry.class, BiomeTintContent.Entry::new)
.documentation("Define a weighted color entry for biome tinting")
.<Color>append(new KeyedCodec<>("Color", ProtocolCodecs.COLOR), (var0, var1) -> var0.color = var1, var0 -> var0.color)
.documentation("The color value")
.add()
.<Double>append(new KeyedCodec<>("Weight", Codec.DOUBLE), (var0, var1) -> var0.weight = var1, var0 -> var0.weight)
.addValidator(Validators.range(0.0, 100.0))
.documentation("The relative weight of this color entry")
.add()
.build();
class="kw">public class="kw">static class="kw">final BiomeTintContent.Entry[] EMPTY_ARRAY = new BiomeTintContent.Entry[0];
class="kw">protected class="kw">static class="kw">final Color DEFAULT_COLOR = new Color();
class="kw">protected Color color = DEFAULT_COLOR;
class="kw">protected double weight = 1.0;
class="kw">public Entry() {
}
class="kw">public Integer color() {
class="kw">return ColorParseUtil.colorToARGBInt(this.color);
}
}
}