Codecs interface
Пакет: com.hypixel.hytale.builtin.worldgen.modifier.content
Файл: com/hypixel/hytale/builtin/worldgen/modifier/content/Codecs.java
Поля (3)
| Модификаторы | Тип | Имя |
|---|---|---|
|
BuilderCodec<IntRange> |
INT_RANGE |
|
float |
var1 |
|
float |
var2 |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.worldgen.modifier.content;
class="kw">import com.hypixel.hytale.assetstore.codec.ContainedAssetCodec;
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.math.range.FloatRange;
class="kw">import com.hypixel.hytale.math.range.IntRange;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
class="kw">public class="kw">interface Codecs {
BuilderCodec<IntRange> INT_RANGE = BuilderCodec.builder(IntRange.class, IntRange::new)
.append(new KeyedCodec<>("Min", Codec.INTEGER), IntRange::setInclusiveMin, IntRange::getInclusiveMin)
.documentation("The inclusive minimum value of the range")
.add()
.append(new KeyedCodec<>("Max", Codec.INTEGER), IntRange::setInclusiveMax, IntRange::getInclusiveMax)
.documentation("The inclusive maximum value of the range")
.add()
.build();
BuilderCodec<FloatRange> DENSITY_RANGE = BuilderCodec.builder(FloatRange.class, FloatRange::new)
.append(new KeyedCodec<>("Min", Codec.FLOAT), FloatRange::setInclusiveMin, FloatRange::getInclusiveMin)
.addValidator(Validators.range(0.0F, 1.0F))
.documentation("The inclusive minimum value of the range")
.add()
.append(new KeyedCodec<>("Max", Codec.FLOAT), FloatRange::setInclusiveMax, FloatRange::getInclusiveMax)
.addValidator(Validators.range(0.0F, 1.0F))
.documentation("The inclusive maximum value of the range")
.add()
.afterDecode(var0 -> {
float var1 = Math.min(var0.getInclusiveMin(), var0.getInclusiveMax());
float var2 = Math.max(var0.getInclusiveMin(), var0.getInclusiveMax());
var0.setInclusiveMin(var1);
var0.setInclusiveMax(var2);
})
.build();
Codec<String> BLOCK_TYPE = new ContainedAssetCodec<>(BlockType.class, BlockType.CODEC);
Codec<String> FLUID_TYPE = new ContainedAssetCodec<>(Fluid.class, Fluid.CODEC);
ArrayCodec<String> BLOCK_TYPE_ARRAY = new ArrayCodec<>(BLOCK_TYPE, String[]::new);
ArrayCodec<String> FLUID_TYPE_ARRAY = new ArrayCodec<>(FLUID_TYPE, String[]::new);
}