PositionProbeBase class
Пакет: com.hypixel.hytale.server.npc.util
Файл: com/hypixel/hytale/server/npc/util/PositionProbeBase.java
Поля (12)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
int |
lastWaterCheckDistanceMinSquared |
|
TransformComponent |
var10 |
|
ChunkStore |
var11 |
|
long |
var12 |
|
Ref |
var14 |
|
int |
var15 |
|
int |
var16 |
|
int |
var17 |
|
Store |
var18 |
|
ChunkColumn |
var19 |
|
BlockChunk |
var20 |
|
World |
var9 |
Методы (16)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
int |
getDepthBelowSurfaceint getDepthBelowSurface() |
public |
int |
getGroundLevelint getGroundLevel() |
public |
int |
getHeightOverGroundint getHeightOverGround() |
public |
int |
getHeightOverSurfaceint getHeightOverSurface() |
public |
int |
getHeightOverWaterint getHeightOverWater() |
public |
int |
getWaterLevelint getWaterLevel() |
|
|
if if(var19 != null && var20 != null) |
|
|
if if(this.waterLevel < this.groundLevel) |
public |
boolean |
isInWaterboolean isInWater() |
public |
boolean |
isOnGroundboolean isOnGround() |
public |
boolean |
isTouchCeilboolean isTouchCeil() |
public |
boolean |
isValidPositionboolean isValidPosition() |
private |
boolean |
movedFarEnoughboolean movedFarEnough(int var1, int var2) |
protected |
<T> boolean |
probePosition<T> boolean probePosition(@Nonnull Ref<EntityStore> var1,
@Nonnull Box var2,
@Nonnull Vector3d var3,
@Nonnull CollisionResult var4,
@Nonnull T var5,
@Nonnull CollisionFilter<BoxBlockIntersectionEvaluator, T> var6,
int var7,
@Nonnull ComponentAccessor<EntityStore> var8) |
protected |
void |
resetvoid reset() |
protected |
int |
updateWaterLevelint updateWaterLevel(@Nonnull ComponentAccessor<ChunkStore> var1, @Nonnull ChunkColumn var2, @Nonnull BlockChunk var3, int var4, int var5) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.util;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.shape.Box;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.server.core.modules.collision.BoxBlockIntersectionEvaluator;
class="kw">import com.hypixel.hytale.server.core.modules.collision.CollisionFilter;
class="kw">import com.hypixel.hytale.server.core.modules.collision.CollisionModule;
class="kw">import com.hypixel.hytale.server.core.modules.collision.CollisionResult;
class="kw">import com.hypixel.hytale.server.core.modules.collision.WorldUtil;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">public class PositionProbeBase {
class="kw">private class="kw">static class="kw">final int lastWaterCheckDistanceMinSquared = 25;
class="kw">protected boolean touchCeil;
class="kw">protected boolean onGround;
class="kw">protected boolean inWater;
class="kw">protected boolean validPosition = true;
class="kw">protected int groundLevel = -1;
class="kw">protected int waterLevel = -1;
class="kw">protected int heightOverGround = -1;
class="kw">protected int heightOverWater = -1;
class="kw">protected int heightOverSurface = -1;
class="kw">protected int depthBelowSurface = -1;
class="kw">private int lastWaterCheckX = Integer.MAX_VALUE;
class="kw">private int lastWaterCheckZ = Integer.MAX_VALUE;
class="kw">private int lastWaterCheckLevel = -2;
class="kw">public PositionProbeBase() {
}
class="kw">protected <T> boolean probePosition(
@Nonnull Ref<EntityStore> var1,
@Nonnull Box var2,
@Nonnull Vector3d var3,
@Nonnull CollisionResult var4,
@Nonnull T var5,
@Nonnull CollisionFilter<BoxBlockIntersectionEvaluator, T> var6,
int var7,
@Nonnull ComponentAccessor<EntityStore> var8
) {
World var9 = var8.getExternalData().getWorld();
TransformComponent var10 = var8.getComponent(var1, TransformComponent.getComponentType());
assert var10 != null;
ChunkStore var11 = var9.getChunkStore();
long var12 = ChunkUtil.indexChunkFromBlock(var3.x, var3.z);
Ref var14 = var11.getChunkReference(var12);
this.reset();
if (var14 != null && var14.isValid()) {
int var15 = MathUtil.floor(var3.x);
int var16 = MathUtil.floor(var3.y);
int var17 = MathUtil.floor(var3.z);
this.validPosition = CollisionModule.get().validatePosition(var9, var2, var3, var7, var5, var6, var4) != -1;
Store var18 = var11.getStore();
ChunkColumn var19 = var18.getComponent(var14, ChunkColumn.getComponentType());
BlockChunk var20 = var18.getComponent(var14, BlockChunk.getComponentType());
if (var19 != null && var20 != null) {
this.groundLevel = var20.getHeight(var15, var17);
this.waterLevel = this.updateWaterLevel(var18, var19, var20, var15, var17);
} else {
this.groundLevel = -1;
this.waterLevel = -1;
this.lastWaterCheckLevel = -2;
}
this.heightOverGround = var16 - this.groundLevel;
if (this.waterLevel < this.groundLevel) {
this.heightOverSurface = this.heightOverGround;
} else if (var16 > this.waterLevel) {
this.heightOverSurface = var16 - this.waterLevel;
} else {
this.depthBelowSurface = this.waterLevel - var16;
}
class="kw">return this.validPosition;
} else {
this.waterLevel = -1;
this.groundLevel = -1;
this.lastWaterCheckLevel = -2;
class="kw">return false;
}
}
class="kw">protected int updateWaterLevel(@Nonnull ComponentAccessor<ChunkStore> var1, @Nonnull ChunkColumn var2, @Nonnull BlockChunk var3, int var4, int var5) {
if (this.lastWaterCheckLevel < -1 || this.movedFarEnough(var4, var5)) {
this.lastWaterCheckX = var4;
this.lastWaterCheckZ = var5;
this.lastWaterCheckLevel = WorldUtil.getWaterLevel(var1, var2, var3, var4, var5, this.groundLevel);
}
class="kw">return this.lastWaterCheckLevel;
}
class="kw">private boolean movedFarEnough(int var1, int var2) {
var1 -= this.lastWaterCheckX;
var2 -= this.lastWaterCheckZ;
class="kw">return var1 * var1 + var2 * var2 > 25;
}
class="kw">protected void reset() {
this.touchCeil = false;
this.onGround = false;
this.inWater = false;
this.validPosition = true;
this.heightOverGround = -1;
this.heightOverSurface = -1;
this.heightOverWater = -1;
this.depthBelowSurface = -1;
}
class="kw">public boolean isValidPosition() {
class="kw">return this.validPosition;
}
class="kw">public boolean isTouchCeil() {
class="kw">return this.touchCeil;
}
class="kw">public boolean isOnGround() {
class="kw">return this.onGround;
}
class="kw">public boolean isInWater() {
class="kw">return this.inWater;
}
class="kw">public int getGroundLevel() {
class="kw">return this.groundLevel;
}
class="kw">public int getWaterLevel() {
class="kw">return this.waterLevel;
}
class="kw">public int getHeightOverGround() {
class="kw">return this.heightOverGround;
}
class="kw">public int getHeightOverSurface() {
class="kw">return this.heightOverSurface;
}
class="kw">public int getDepthBelowSurface() {
class="kw">return this.depthBelowSurface;
}
class="kw">public int getHeightOverWater() {
class="kw">return this.heightOverWater;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "PositionProbeBase{touchCeil="
+ this.touchCeil
+ ", onGround="
+ this.onGround
+ ", inWater="
+ this.inWater
+ ", validPosition="
+ this.validPosition
+ ", groundLevel="
+ this.groundLevel
+ ", waterLevel="
+ this.waterLevel
+ ", heightOverGround="
+ this.heightOverGround
+ ", heightOverSurface="
+ this.heightOverSurface
+ ", depthBelowSurface="
+ this.depthBelowSurface
+ ", heightOverWater="
+ this.heightOverWater
+ ", lastWaterCheckX="
+ this.lastWaterCheckX
+ ", lastWaterCheckZ="
+ this.lastWaterCheckZ
+ ", lastWaterCheckLevel="
+ this.lastWaterCheckLevel
+ "}";
}
}