NoiseHeightThresholdInterpreter class
Пакет: com.hypixel.hytale.procedurallib.condition
Файл: com/hypixel/hytale/procedurallib/condition/NoiseHeightThresholdInterpreter.java
implements: IHeightThresholdInterpreter
Поля (8)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
NoiseProperty |
noise |
|
int |
var1 |
|
int |
var10 |
|
|
var10 |
|
float |
var11 |
|
int |
var4 |
|
|
var4 |
|
int |
var9 |
Методы (14)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("Length of keys and values are different!") |
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("ThresholdKeyInterpreter have different size!") |
static |
void |
checkInterpreterLengthvoid checkInterpreterLength(@Nonnull IHeightThresholdInterpreter[] var0) |
abstract |
|
checkInterpreterLength checkInterpreterLength(var3) |
|
|
for for(IHeightThresholdInterpreter var8 : var3) |
|
|
for for(IHeightThresholdInterpreter var9 : var3) |
|
|
for for(int var10 = 0; var10 < var9; var10++) |
|
|
for for(int var2 = 1; var2 < var0.length; var2++) |
|
|
if if(var2.length != var3.length) |
|
|
if if(var6 > this.highestNonZero) |
|
|
if if(var7 <= this.keys[var10]) |
|
|
if if(var10 == 0) |
static |
float |
lerpfloat lerp(float var0, float var1, float var2) |
protected |
double |
noisedouble noise(int var1, double var2, double var4) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.procedurallib.condition;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseProperty;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">public class NoiseHeightThresholdInterpreter class="kw">implements IHeightThresholdInterpreter {
class="kw">protected class="kw">final NoiseProperty noise;
@Nonnull
class="kw">protected class="kw">final float[] keys;
@Nonnull
class="kw">protected class="kw">final IHeightThresholdInterpreter[] values;
class="kw">protected class="kw">final int length;
class="kw">protected class="kw">final int lowestNonOne;
class="kw">protected class="kw">final int highestNonZero;
class="kw">public NoiseHeightThresholdInterpreter(NoiseProperty var1, @Nonnull float[] var2, @Nonnull IHeightThresholdInterpreter[] var3) {
if (var2.length != var3.length) {
throw new IllegalStateException("Length of keys and values are different!");
}
checkInterpreterLength(var3);
this.noise = var1;
this.keys = var2;
this.values = var3;
this.length = var3[0].getLength();
int var4 = this.length - 1;
for (IHeightThresholdInterpreter var8 : var3) {
if (var8.getLowestNonOne() < var4) {
var4 = var8.getLowestNonOne();
}
}
this.lowestNonOne = var4;
int var10 = 0;
for (IHeightThresholdInterpreter var9 : var3) {
if (var9.getHighestNonZero() > var10) {
var10 = var9.getHighestNonZero();
}
}
this.highestNonZero = var10;
}
@Override
class="kw">public int getLowestNonOne() {
class="kw">return this.lowestNonOne;
}
@Override
class="kw">public int getHighestNonZero() {
class="kw">return this.highestNonZero;
}
class="kw">protected double noise(int var1, double var2, double var4) {
class="kw">return this.noise.get(var1, var2, var4);
}
@Override
class="kw">public double getContext(int var1, double var2, double var4) {
class="kw">return this.noise(var1, var2, var4);
}
@Override
class="kw">public int getLength() {
class="kw">return this.length;
}
@Override
class="kw">public float getThreshold(int var1, double var2, double var4, int var6) {
class="kw">return this.getThreshold(var1, var2, var4, var6, this.getContext(var1, var2, var4));
}
@Override
class="kw">public float getThreshold(int var1, double var2, double var4, int var6, double var7) {
if (var6 > this.highestNonZero) {
class="kw">return 0.0F;
}
int var9 = this.keys.length;
for (int var10 = 0; var10 < var9; var10++) {
if (var7 <= this.keys[var10]) {
if (var10 == 0) {
class="kw">return this.values[0].getThreshold(var1, var2, var4, var6);
}
float var11 = ((float)var7 - this.keys[var10 - 1]) / (this.keys[var10] - this.keys[var10 - 1]);
class="kw">return IHeightThresholdInterpreter.lerp(
this.values[var10 - 1].getThreshold(var1, var2, var4, var6), this.values[var10].getThreshold(var1, var2, var4, var6), var11
);
}
}
class="kw">return this.values[var9 - 1].getThreshold(var1, var2, var4, var6);
}
class="kw">static float lerp(float var0, float var1, float var2) {
class="kw">return var0 + (var1 - var0) * var2;
}
class="kw">private class="kw">static void checkInterpreterLength(@Nonnull IHeightThresholdInterpreter[] var0) {
int var1 = var0[0].getLength();
for (int var2 = 1; var2 < var0.length; var2++) {
if (var0[var2].getLength() != var1) {
throw new IllegalStateException("ThresholdKeyInterpreter have different size!");
}
}
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "NoiseHeightThresholdInterpreter{noise="
+ this.noise
+ ", keys="
+ Arrays.toString(this.keys)
+ ", values="
+ Arrays.toString(this.values)
+ ", length="
+ this.length
+ ", lowestNonOne="
+ this.lowestNonOne
+ ", highestNonZero="
+ this.highestNonZero
+ "}";
}
}