Constants interface
Пакет: com.hypixel.hytale.procedurallib.condition
Файл: com/hypixel/hytale/procedurallib/condition/BasicHeightThresholdInterpreter.java
Поля (1)
| Модификаторы | Тип | Имя |
|---|---|---|
|
String |
ERROR_ARRAY_LENGTH |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.procedurallib.condition;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">public class BasicHeightThresholdInterpreter class="kw">implements IHeightThresholdInterpreter {
@Nonnull
class="kw">protected class="kw">final float[] interpolatedThresholds;
class="kw">protected class="kw">final int lowestNonOne;
class="kw">protected class="kw">final int highestNonZero;
class="kw">public BasicHeightThresholdInterpreter(@Nonnull int[] var1, @Nonnull float[] var2, int var3) {
if (var1.length != var2.length) {
throw new IllegalArgumentException(String.format("Mismatching array lengths! positions: %s, thresholds: %s", var1.length, var2.length));
}
this.interpolatedThresholds = new float[var3];
for (int var4 = 0; var4 < this.interpolatedThresholds.length; var4++) {
float var5 = var2[var2.length - 1];
for (int var6 = 0; var6 < var1.length; var6++) {
if (var4 < var1[var6]) {
if (var6 == 0) {
var5 = var2[var6];
} else {
float var7 = (float)(var4 - var1[var6 - 1]) / (var1[var6] - var1[var6 - 1]);
var5 = IHeightThresholdInterpreter.lerp(var2[var6 - 1], var2[var6], var7);
}
break;
}
}
this.interpolatedThresholds[var4] = var5;
}
int var8 = 0;
while (var8 < var3 && !(this.interpolatedThresholds[var8] < 1.0F)) {
var8++;
}
this.lowestNonOne = var8;
int var9 = var3 - 1;
while (var9 >= 0 && !(this.interpolatedThresholds[var9] > 0.0F)) {
var9--;
}
this.highestNonZero = var9;
}
@Override
class="kw">public int getLowestNonOne() {
class="kw">return this.lowestNonOne;
}
@Override
class="kw">public int getHighestNonZero() {
class="kw">return this.highestNonZero;
}
@Override
class="kw">public double getContext(int var1, double var2, double var4) {
class="kw">return 0.0;
}
@Override
class="kw">public int getLength() {
class="kw">return this.interpolatedThresholds.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;
}
if (var6 < 0) {
var6 = 0;
}
if (var6 >= this.interpolatedThresholds.length) {
var6 = this.interpolatedThresholds.length - 1;
}
class="kw">return this.interpolatedThresholds[var6];
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "BasicHeightThresholdInterpreter{interpolatedThresholds="
+ Arrays.toString(this.interpolatedThresholds)
+ ", lowestNonOne="
+ this.lowestNonOne
+ ", highestNonZero="
+ this.highestNonZero
+ "}";
}
class="kw">public class="kw">interface Constants {
String ERROR_ARRAY_LENGTH = "Mismatching array lengths! positions: %s, thresholds: %s";
}
}