DensityProp class
Пакет: com.hypixel.hytale.builtin.hytalegenerator.props
Файл: com/hypixel/hytale/builtin/hytalegenerator/props/DensityProp.java
extends: Prop
Поля (10)
| Модификаторы | Тип | Имя |
|---|---|---|
|
Material |
var10 |
|
Bounds3i |
var2 |
|
Bounds3i |
var3 |
|
int |
var4 |
|
double |
var4 |
|
boolean |
var5 |
|
int |
var6 |
|
int |
var7 |
|
int |
var8 |
|
boolean |
var9 |
Методы (12)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(this.rPosition.x = this.rIntersectingWriteBounds.min.x; this.rPosition.x < this.rIntersectingWriteBounds.max.x; this.rPosition.x++) |
|
|
for for(this.rPosition.y = this.rIntersectingWriteBounds.min.y; this.rPosition.y < this.rIntersectingWriteBounds.max.y; this.rPosition.y++) |
|
|
for for(this.rPosition.z = this.rIntersectingWriteBounds.min.z; this.rPosition.z < this.rIntersectingWriteBounds.max.z; this.rPosition.z++) |
|
|
for for(this.rPosition.x = this.rIntersectingWriteBounds.min.x; this.rPosition.x < this.rIntersectingWriteBounds.max.x; this.rPosition.x++) |
|
|
for for(this.rPosition.z = this.rIntersectingWriteBounds.min.z; this.rPosition.z < this.rIntersectingWriteBounds.max.z; this.rPosition.z++) |
|
|
for for(this.rPosition.y = this.rIntersectingWriteBounds.max.y - 2; this.rPosition.y > this.rIntersectingWriteBounds.min.y; this.rPosition.y--) |
|
|
for for(this.rPosition.y = this.rIntersectingWriteBounds.min.y + 1; this.rPosition.y < this.rIntersectingWriteBounds.max.y - 1; this.rPosition.y++) |
|
|
for for(this.rPosition.y = this.rIntersectingWriteBounds.max.y - 2; this.rPosition.y > this.rIntersectingWriteBounds.min.y; this.rPosition.y--) |
|
|
if if(this.rPosition.y == this.rIntersectingWriteBounds.max.y - 1) |
|
|
if if(var5) |
|
|
if if(this.rPosition.y == this.rIntersectingWriteBounds.min.x) |
|
|
if if(var9) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.hytalegenerator.props;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.bounds.Bounds3i;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.density.Density;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.material.Material;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.materialproviders.MaterialProvider;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.voxelspace.ArrayVoxelSpace;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;
class="kw">public class DensityProp class="kw">extends Prop {
@Nonnull
class="kw">private class="kw">final Density density;
@Nonnull
class="kw">private class="kw">final MaterialProvider<Material> materialProvider;
@Nonnull
class="kw">private class="kw">final Bounds3i writeBounds;
@Nonnull
class="kw">private class="kw">final Bounds3i solidityBufferBounds;
@Nonnull
class="kw">private class="kw">final Bounds3i rIntersectingWriteBounds;
@Nonnull
class="kw">private class="kw">final ArrayVoxelSpace<Boolean> rSolidityBuffer;
@Nonnull
class="kw">private class="kw">final Density.Context rDensityContext;
@Nonnull
class="kw">private class="kw">final MaterialProvider.Context rMaterialProviderContext;
@Nonnull
class="kw">private class="kw">final Vector3i rPosition;
@Nonnull
class="kw">private class="kw">final int[] rDepthIntoCeiling;
@Nonnull
class="kw">private class="kw">final int[] rDepthIntoFloor;
@Nonnull
class="kw">private class="kw">final int[] rSpaceBelowCeiling;
@Nonnull
class="kw">private class="kw">final int[] rSpaceAboveFloor;
class="kw">public DensityProp(@Nonnull Density var1, @Nonnull MaterialProvider<Material> var2, @Nonnull Bounds3i var3) {
this.density = var1;
this.materialProvider = var2;
this.writeBounds = var3.clone();
this.solidityBufferBounds = var3.clone();
this.solidityBufferBounds.min.y--;
this.solidityBufferBounds.max.y++;
this.rSolidityBuffer = new ArrayVoxelSpace<>(this.solidityBufferBounds);
this.rIntersectingWriteBounds = new Bounds3i();
this.rDensityContext = new Density.Context();
this.rDensityContext.densityAnchor = new Vector3d();
this.rMaterialProviderContext = new MaterialProvider.Context();
this.rPosition = new Vector3i();
int var4 = this.writeBounds.max.y - this.writeBounds.min.y + 2;
this.rDepthIntoCeiling = new int[var4 + 1];
this.rDepthIntoFloor = new int[var4 + 1];
this.rSpaceBelowCeiling = new int[var4 + 1];
this.rSpaceAboveFloor = new int[var4 + 1];
}
@Override
class="kw">public boolean generate(@Nonnull Prop.Context var1) {
Bounds3i var2 = var1.materialWriteSpace.getBounds();
this.rIntersectingWriteBounds.assign(this.writeBounds);
this.rIntersectingWriteBounds.offset(var1.position);
Bounds3i var3 = this.rSolidityBuffer.getBounds();
var3.assign(this.solidityBufferBounds);
var3.offset(var1.position);
this.rIntersectingWriteBounds.min.x = Math.max(this.rIntersectingWriteBounds.min.x, var2.min.x);
this.rIntersectingWriteBounds.min.z = Math.max(this.rIntersectingWriteBounds.min.z, var2.min.z);
this.rIntersectingWriteBounds.max.x = Math.min(this.rIntersectingWriteBounds.max.x, var2.max.x);
this.rIntersectingWriteBounds.max.z = Math.min(this.rIntersectingWriteBounds.max.z, var2.max.z);
this.rIntersectingWriteBounds.min.y--;
this.rIntersectingWriteBounds.max.y++;
assert this.rDensityContext.densityAnchor != null;
this.rDensityContext.densityAnchor.set(var1.position);
for (this.rPosition.x = this.rIntersectingWriteBounds.min.x; this.rPosition.x < this.rIntersectingWriteBounds.max.x; this.rPosition.x++) {
for (this.rPosition.y = this.rIntersectingWriteBounds.min.y; this.rPosition.y < this.rIntersectingWriteBounds.max.y; this.rPosition.y++) {
for (this.rPosition.z = this.rIntersectingWriteBounds.min.z; this.rPosition.z < this.rIntersectingWriteBounds.max.z; this.rPosition.z++) {
this.rDensityContext.position.set(this.rPosition);
double var4 = this.density.process(this.rDensityContext);
this.rSolidityBuffer.set(var4 > 0.0 ? Boolean.TRUE : Boolean.FALSE, this.rPosition);
}
}
}
for (this.rPosition.x = this.rIntersectingWriteBounds.min.x; this.rPosition.x < this.rIntersectingWriteBounds.max.x; this.rPosition.x++) {
for (this.rPosition.z = this.rIntersectingWriteBounds.min.z; this.rPosition.z < this.rIntersectingWriteBounds.max.z; this.rPosition.z++) {
for (this.rPosition.y = this.rIntersectingWriteBounds.max.y - 2; this.rPosition.y > this.rIntersectingWriteBounds.min.y; this.rPosition.y--) {
int var6 = this.rPosition.y - this.rIntersectingWriteBounds.min.y;
boolean var5 = this.rSolidityBuffer.get(this.rPosition.x, this.rPosition.y, this.rPosition.z);
if (this.rPosition.y == this.rIntersectingWriteBounds.max.y - 1) {
if (var5) {
this.rDepthIntoFloor[var6] = 1;
} else {
this.rDepthIntoFloor[var6] = 0;
}
this.rSpaceAboveFloor[var6] = 1073741823;
} else if (var5) {
this.rDepthIntoFloor[var6] = this.rDepthIntoFloor[var6 + 1] + 1;
this.rSpaceAboveFloor[var6] = this.rSpaceAboveFloor[var6 + 1];
} else {
this.rDepthIntoFloor[var6] = 0;
if (this.rSolidityBuffer.get(this.rPosition.x, this.rPosition.y + 1, this.rPosition.z)) {
this.rSpaceAboveFloor[var6] = 0;
} else {
this.rSpaceAboveFloor[var6] = this.rSpaceAboveFloor[var6 + 1] + 1;
}
}
}
for (this.rPosition.y = this.rIntersectingWriteBounds.min.y + 1; this.rPosition.y < this.rIntersectingWriteBounds.max.y - 1; this.rPosition.y++) {
int var7 = this.rPosition.y - this.rIntersectingWriteBounds.min.y;
boolean var9 = this.rSolidityBuffer.get(this.rPosition.x, this.rPosition.y, this.rPosition.z);
if (this.rPosition.y == this.rIntersectingWriteBounds.min.x) {
if (var9) {
this.rDepthIntoCeiling[var7] = 1;
} else {
this.rDepthIntoCeiling[var7] = 0;
}
this.rSpaceBelowCeiling[var7] = Integer.MAX_VALUE;
} else if (var9) {
this.rDepthIntoCeiling[var7] = this.rDepthIntoCeiling[var7 - 1] + 1;
this.rSpaceBelowCeiling[var7] = this.rSpaceBelowCeiling[var7 - 1];
} else {
this.rDepthIntoCeiling[var7] = 0;
if (this.rSolidityBuffer.get(this.rPosition.x, this.rPosition.y - 1, this.rPosition.z)) {
this.rSpaceBelowCeiling[var7] = 0;
} else {
this.rSpaceBelowCeiling[var7] = this.rSpaceBelowCeiling[var7 - 1] + 1;
}
}
}
for (this.rPosition.y = this.rIntersectingWriteBounds.max.y - 2; this.rPosition.y > this.rIntersectingWriteBounds.min.y; this.rPosition.y--) {
if (this.rIntersectingWriteBounds.contains(this.rPosition)) {
int var8 = this.rPosition.y - this.rIntersectingWriteBounds.min.y;
this.rMaterialProviderContext.position.set(this.rPosition);
this.rMaterialProviderContext.depthIntoFloor = this.rDepthIntoFloor[var8];
this.rMaterialProviderContext.depthIntoCeiling = this.rDepthIntoCeiling[var8];
this.rMaterialProviderContext.spaceAboveFloor = this.rSpaceAboveFloor[var8];
this.rMaterialProviderContext.spaceBelowCeiling = this.rSpaceBelowCeiling[var8];
this.rMaterialProviderContext.distanceToBiomeEdge = var1.distanceToBiomeEdge;
Material var10 = this.materialProvider.getVoxelTypeAt(this.rMaterialProviderContext);
if (var10 != null && var1.materialWriteSpace.getBounds().contains(this.rPosition)) {
var1.materialWriteSpace.set(var10, this.rPosition);
}
}
}
}
}
class="kw">return true;
}
@Nonnull
@Override
class="kw">public Bounds3i getReadBounds_voxelGrid() {
class="kw">return Bounds3i.ZERO;
}
@Nonnull
@Override
class="kw">public Bounds3i getWriteBounds_voxelGrid() {
class="kw">return this.writeBounds;
}
}