PrefabCaveNodeShape class
Пакет: com.hypixel.hytale.server.worldgen.cave.shape
Файл: com/hypixel/hytale/server/worldgen/cave/shape/PrefabCaveNodeShape.java
implements: CaveNodeShape, IWorldBounds
Поля (22)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
CaveType |
caveType |
|
private final BlockMaskCondition |
configuration |
|
private final List<WorldGenPrefabSupplier> |
prefabs |
|
int |
var10 |
|
PrefabRotation |
var10 |
|
|
var10 |
|
double |
var11 |
|
long |
var11 |
|
double |
var13 |
|
PrefabPasteUtil.PrefabPasteBuffer |
var13 |
|
PrefabRotation |
var13 |
|
PrefabRotation |
var14 |
|
int |
var6 |
|
IPrefabBuffer |
var7 |
|
int |
var7 |
|
IChunkBounds |
var8 |
|
Vector3d |
var8 |
|
int |
var8 |
|
WorldGenPrefabSupplier |
var8 |
|
double |
var9 |
|
int |
var9 |
|
Vector3d |
var9 |
Методы (5)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public |
PrefabCaveNodeShapeGeneratorpublic PrefabCaveNodeShapeGenerator(List<WorldGenPrefabSupplier> var1, BlockMaskCondition var2) |
abstract |
return new |
Vector3dreturn new Vector3d(this.o) |
|
public CaveNodeShape |
generateCaveNodeShapepublic CaveNodeShape generateCaveNodeShape(@Nonnull Random var1,
CaveType var2,
@Nullable CaveNode var3,
@Nonnull CaveNodeType.CaveNodeChildEntry var4,
@Nonnull Vector3d var5,
float var6,
float var7) |
public |
CaveType |
getCaveTypeCaveType getCaveType() |
|
|
if if(var3 == null) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.cave.shape;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.util.HashUtil;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.server.core.prefab.PrefabRotation;
class="kw">import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
class="kw">import com.hypixel.hytale.server.worldgen.cave.Cave;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveNodeType;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveType;
class="kw">import com.hypixel.hytale.server.worldgen.cave.element.CaveNode;
class="kw">import com.hypixel.hytale.server.worldgen.chunk.ChunkGenerator;
class="kw">import com.hypixel.hytale.server.worldgen.chunk.ChunkGeneratorExecution;
class="kw">import com.hypixel.hytale.server.worldgen.loader.WorldGenPrefabSupplier;
class="kw">import com.hypixel.hytale.server.worldgen.prefab.PrefabPasteUtil;
class="kw">import com.hypixel.hytale.server.worldgen.util.bounds.IChunkBounds;
class="kw">import com.hypixel.hytale.server.worldgen.util.bounds.IWorldBounds;
class="kw">import com.hypixel.hytale.server.worldgen.util.condition.BlockMaskCondition;
class="kw">import java.util.List;
class="kw">import java.util.Random;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3dc;
class="kw">public class PrefabCaveNodeShape class="kw">implements CaveNodeShape, IWorldBounds {
class="kw">private class="kw">final CaveType caveType;
@Nonnull
class="kw">private class="kw">final Vector3dc o;
class="kw">private class="kw">final Vector3dc e;
@Nonnull
class="kw">private class="kw">final WorldGenPrefabSupplier prefabSupplier;
@Nonnull
class="kw">private class="kw">final PrefabRotation rotation;
class="kw">private class="kw">final BlockMaskCondition configuration;
class="kw">private class="kw">final int lowBoundX;
class="kw">private class="kw">final int lowBoundY;
class="kw">private class="kw">final int lowBoundZ;
class="kw">private class="kw">final int highBoundX;
class="kw">private class="kw">final int highBoundY;
class="kw">private class="kw">final int highBoundZ;
class="kw">public PrefabCaveNodeShape(
CaveType var1, @Nonnull Vector3dc var2, Vector3dc var3, @Nonnull WorldGenPrefabSupplier var4, @Nonnull PrefabRotation var5, BlockMaskCondition var6
) {
this.caveType = var1;
this.o = var2;
this.e = var3;
this.prefabSupplier = var4;
this.rotation = var5;
this.configuration = var6;
IPrefabBuffer var7 = var4.get();
IChunkBounds var8 = var4.getBounds(var7);
this.lowBoundX = MathUtil.floor(var2.x() + var8.getLowBoundX(var5));
this.lowBoundY = MathUtil.floor(var2.y() + var7.getMinY());
this.lowBoundZ = MathUtil.floor(var2.z() + var8.getLowBoundZ(var5));
this.highBoundX = MathUtil.ceil(var2.x() + var8.getHighBoundX(var5));
this.highBoundY = MathUtil.ceil(var2.y() + var7.getMaxY());
this.highBoundZ = MathUtil.ceil(var2.z() + var8.getHighBoundZ(var5));
}
class="kw">public CaveType getCaveType() {
class="kw">return this.caveType;
}
@Nonnull
class="kw">public PrefabRotation getPrefabRotation() {
class="kw">return this.rotation;
}
@Nonnull
class="kw">public Vector3dc getO() {
class="kw">return this.o;
}
@Nonnull
@Override
class="kw">public Vector3d getStart() {
class="kw">return new Vector3d(this.o);
}
@Nonnull
@Override
class="kw">public Vector3d getEnd() {
class="kw">return new Vector3d(this.o).add(this.e);
}
@Nonnull
@Override
class="kw">public Vector3d getAnchor(@Nonnull Vector3d var1, double var2, double var4, double var6) {
Vector3d var8 = CaveNodeShapeUtils.getBoxAnchor(var1, this, var2, var4, var6);
double var9 = MathUtil.floor(var8.x) + 0.5;
double var11 = MathUtil.floor(var8.y) + 0.5;
double var13 = MathUtil.floor(var8.z) + 0.5;
class="kw">return var8.set(var9, var11, var13);
}
@Nonnull
@Override
class="kw">public IWorldBounds getBounds() {
class="kw">return this;
}
@Override
class="kw">public int getLowBoundX() {
class="kw">return this.lowBoundX;
}
@Override
class="kw">public int getLowBoundZ() {
class="kw">return this.lowBoundZ;
}
@Override
class="kw">public int getHighBoundX() {
class="kw">return this.highBoundX;
}
@Override
class="kw">public int getHighBoundZ() {
class="kw">return this.highBoundZ;
}
@Override
class="kw">public int getLowBoundY() {
class="kw">return this.lowBoundY;
}
@Override
class="kw">public int getHighBoundY() {
class="kw">return this.highBoundY;
}
@Override
class="kw">public boolean shouldReplace(int var1, double var2, double var4, int var6) {
class="kw">return false;
}
@Override
class="kw">public double getFloorPosition(int var1, double var2, double var4) {
var2 -= this.o.x();
var4 -= this.o.z();
class="kw">return this.prefabSupplier.get().getMinYAt(this.rotation, (int)var2, (int)var4);
}
@Override
class="kw">public double getCeilingPosition(int var1, double var2, double var4) {
var2 -= this.o.x();
var4 -= this.o.z();
class="kw">return this.prefabSupplier.get().getMaxYAt(this.rotation, (int)var2, (int)var4);
}
@Override
class="kw">public void populateChunk(int var1, @Nonnull ChunkGeneratorExecution var2, @Nonnull Cave var3, @Nonnull CaveNode var4, Random var5) {
int var6 = MathUtil.floor(this.o.x());
int var7 = MathUtil.floor(this.o.y());
int var8 = MathUtil.floor(this.o.z());
int var9 = var6 - ChunkUtil.minBlock(var2.getX());
int var10 = var8 - ChunkUtil.minBlock(var2.getZ());
long var11 = HashUtil.hash(Double.doubleToLongBits(this.o.x()), Double.doubleToLongBits(this.o.z())) * 1406794441L;
PrefabPasteUtil.PrefabPasteBuffer var13 = ChunkGenerator.getResource().prefabBuffer;
var13.setSeed(var1, var11);
var13.execution = var2;
var13.blockMask = this.configuration;
var13.environmentId = var4.getCaveNodeType().hasEnvironment() ? var4.getCaveNodeType().getEnvironment() : this.caveType.getEnvironment();
var13.priority = 8;
if (var2.getChunkGenerator().getBenchmark().isEnabled() && ChunkUtil.isInsideChunkRelative(var9, var10)) {
var2.getChunkGenerator()
.getBenchmark()
.registerPrefab("CaveNode: " + var3.getCaveType().getName() + "\t" + var4.getCaveNodeType().getName() + "\t" + this.prefabSupplier.getName());
}
PrefabPasteUtil.generate(var13, this.rotation, this.prefabSupplier, var6, var7, var8, var9, var10);
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "PrefabCaveNodeShape{caveType="
+ this.caveType
+ ", o="
+ this.o
+ ", e="
+ this.e
+ ", prefabSupplier=\"prefab\", rotation="
+ this.rotation
+ ", configuration="
+ this.configuration
+ ", lowBoundX="
+ this.lowBoundX
+ ", lowBoundY="
+ this.lowBoundY
+ ", lowBoundZ="
+ this.lowBoundZ
+ ", highBoundX="
+ this.highBoundX
+ ", highBoundY="
+ this.highBoundY
+ ", highBoundZ="
+ this.highBoundZ
+ "}";
}
class="kw">public class="kw">static class PrefabCaveNodeShapeGenerator class="kw">implements CaveNodeShapeEnum.CaveNodeShapeGenerator {
class="kw">private class="kw">final List<WorldGenPrefabSupplier> prefabs;
class="kw">private class="kw">final BlockMaskCondition configuration;
class="kw">public PrefabCaveNodeShapeGenerator(List<WorldGenPrefabSupplier> var1, BlockMaskCondition var2) {
this.prefabs = var1;
this.configuration = var2;
}
@Nonnull
@Override
class="kw">public CaveNodeShape generateCaveNodeShape(
@Nonnull Random var1,
CaveType var2,
@Nullable CaveNode var3,
@Nonnull CaveNodeType.CaveNodeChildEntry var4,
@Nonnull Vector3d var5,
float var6,
float var7
) {
WorldGenPrefabSupplier var8 = this.prefabs.get(var1.nextInt(this.prefabs.size()));
if (var3 == null) {
PrefabRotation var13 = PrefabRotation.VALUES[var1.nextInt(PrefabRotation.VALUES.length)];
class="kw">return new PrefabCaveNodeShape(var2, var5, Vector3dUtil.ZERO, var8, var13, this.configuration);
}
Vector3d var9 = new Vector3d(var4.getOffset());
PrefabRotation var10 = var4.getRotation(var1);
if (var3.getShape() class="kw">instanceof PrefabCaveNodeShape var11) {
PrefabRotation var14 = var11.getPrefabRotation();
var14.rotate(var9);
var10 = var10.add(var14);
}
var5.add(var9);
class="kw">return new PrefabCaveNodeShape(var2, var5, Vector3dUtil.ZERO, var8, var10, this.configuration);
}
}
}