InFluidCondition class
Пакет: com.hypixel.hytale.server.core.modules.entity.condition
Файл: com/hypixel/hytale/server/core/modules/entity/condition/InFluidCondition.java
extends: Condition
Поля (13)
| Модификаторы | Тип | Имя |
|---|---|---|
|
Box |
var10 |
|
Fluid |
var2 |
|
AssetExtraInfo.Data |
var3 |
|
Int2ObjectMap |
var4 |
|
TransformComponent |
var4 |
|
BoundingBox |
var5 |
|
World |
var6 |
|
Ref |
var6 |
|
ChunkStore |
var7 |
|
long |
var7 |
|
Store |
var8 |
|
Vector3d |
var9 |
|
int |
var9 |
Методы (8)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(int var8 : this.tagIndexes) |
|
|
if if(var0.fluidIds != null) |
|
|
if if(var0.tags != null) |
|
|
if if(this.tagIndexes != null && this.tagIndexes.length > 0) |
|
|
if if(var2 != null) |
|
|
if if(var3 != null) |
|
|
if if(var5 == null) |
private |
boolean |
isMatchingFluidboolean isMatchingFluid(int var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.entity.condition;
class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
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.asset.type.fluid.Fluid;
class="kw">import com.hypixel.hytale.server.core.modules.collision.WorldUtil;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
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.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.time.Instant;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">public class InFluidCondition class="kw">extends Condition {
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<InFluidCondition> CODEC = BuilderCodec.builder(InFluidCondition.class, InFluidCondition::new, Condition.BASE_CODEC)
.appendInherited(
new KeyedCodec<>("FluidIds", new ArrayCodec<>(Codec.STRING, String[]::new)),
(var0, var1) -> var0.fluidIds = var1,
var0 -> var0.fluidIds,
(var0, var1) -> var0.fluidIds = var1.fluidIds
)
.addValidatorLate(() -> Fluid.VALIDATOR_CACHE.getArrayValidator().late())
.documentation("Fluid IDs to match against. Returns true when at least one block within the entity's bounding box contains one of these fluids.")
.add()
.<String[]>appendInherited(
new KeyedCodec<>("Tags", new ArrayCodec<>(Codec.STRING, String[]::new)),
(var0, var1) -> var0.tags = var1,
var0 -> var0.tags,
(var0, var1) -> var0.tags = var1.tags
)
.documentation(
"Fluid tags to match against. Returns true when at least one block within the entity's bounding box contains a fluid with any of these tags."
)
.add()
.afterDecode(var0 -> {
if (var0.fluidIds != null) {
var0.fluidIndexes = Arrays.stream(var0.fluidIds).mapToInt(var0x -> Fluid.getAssetMap().getIndex(var0x)).sorted().toArray();
}
if (var0.tags != null) {
var0.tagIndexes = Arrays.stream(var0.tags).mapToInt(AssetRegistry::getOrCreateTagIndex).sorted().toArray();
}
})
.build();
@Nullable
class="kw">protected String[] fluidIds;
@Nullable
class="kw">protected String[] tags;
@Nullable
class="kw">private class="kw">transient int[] fluidIndexes;
@Nullable
class="kw">private class="kw">transient int[] tagIndexes;
class="kw">protected InFluidCondition() {
}
class="kw">private boolean isMatchingFluid(int var1) {
if (this.fluidIndexes != null && this.fluidIndexes.length > 0 && Arrays.binarySearch(this.fluidIndexes, var1) >= 0) {
class="kw">return true;
}
if (this.tagIndexes != null && this.tagIndexes.length > 0) {
Fluid var2 = Fluid.getAssetMap().getAsset(var1);
if (var2 != null) {
AssetExtraInfo.Data var3 = var2.getData();
if (var3 != null) {
Int2ObjectMap var4 = var3.getTags();
for (int var8 : this.tagIndexes) {
if (var4.containsKey(var8)) {
class="kw">return true;
}
}
}
}
}
class="kw">return false;
}
@Override
class="kw">public boolean eval0(@Nonnull ComponentAccessor<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull Instant var3) {
TransformComponent var4 = var1.getComponent(var2, TransformComponent.getComponentType());
assert var4 != null;
BoundingBox var5 = var1.getComponent(var2, BoundingBox.getComponentType());
if (var5 == null) {
class="kw">return false;
}
World var6 = var1.getExternalData().getWorld();
ChunkStore var7 = var6.getChunkStore();
Store var8 = var7.getStore();
Vector3d var9 = var4.getPosition();
Box var10 = var5.getBoundingBox();
class="kw">return !var10.forEachBlock(var9.x, var9.y, var9.z, 0.0, (var3x, var4x, var5x) -> {
Ref var6 = var7.getChunkReference(ChunkUtil.indexChunkFromBlock(var3x, var5x));
if (var6 != null && var6.isValid()) {
long var7 = WorldUtil.getPackedMaterialAndFluidAtPosition(var6, var8, var3x, var4x, var5x);
int var9 = MathUtil.unpackRight(var7);
class="kw">return var9 == 0 || !this.isMatchingFluid(var9);
} else {
class="kw">return true;
}
});
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "InFluidCondition{fluidIds=" + Arrays.toString(this.fluidIds) + ", tags=" + Arrays.toString(this.tags) + "} " + super.toString();
}
}