BlockMountComponent class
Пакет: com.hypixel.hytale.builtin.mounts
Файл: com/hypixel/hytale/builtin/mounts/BlockMountComponent.java
implements: Component<ChunkStore>
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
private |
BlockMountType |
type |
|
BlockMountComponent |
var1 |
|
Vector3d |
var11 |
|
double |
var12 |
|
BlockMountPoint |
var2 |
|
double |
var4 |
|
|
var4 |
|
BlockMountPoint |
var6 |
|
|
var6 |
Методы (12)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
private |
void |
cleanvoid clean() |
|
|
for for(BlockMountPoint var10 : var2) |
public |
Vector3i |
getBlockPosVector3i getBlockPos() |
static |
ComponentType<ChunkStore, BlockMountComponent> |
getComponentTypeComponentType<ChunkStore, BlockMountComponent> getComponentType() |
public |
BlockType |
getExpectedBlockTypeBlockType getExpectedBlockType() |
public |
int |
getExpectedRotationint getExpectedRotation() |
public |
BlockMountType |
getTypeBlockMountType getType() |
|
|
if if(var2 != null) |
|
|
if if(var12 < var4) |
public |
boolean |
isDeadboolean isDead() |
public |
void |
putSeatedEntityvoid putSeatedEntity(@Nonnull BlockMountPoint var1, @Nonnull Ref<EntityStore> var2) |
public |
void |
removeSeatedEntityvoid removeSeatedEntity(@Nonnull Ref<EntityStore> var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.mounts;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.protocol.BlockMountType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.mountpoints.BlockMountPoint;
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.objects.Object2ReferenceOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
class="kw">import java.util.Collection;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;
class="kw">public class BlockMountComponent class="kw">implements Component<ChunkStore> {
class="kw">private BlockMountType type;
class="kw">private Vector3i blockPos;
class="kw">private BlockType expectedBlockType;
class="kw">private int expectedRotation;
@Nonnull
class="kw">private Map<BlockMountPoint, Ref<EntityStore>> entitiesByMountPoint = new Object2ReferenceOpenHashMap();
@Nonnull
class="kw">private Map<Ref<EntityStore>, BlockMountPoint> mountPointByEntity = new Reference2ObjectOpenHashMap();
class="kw">public class="kw">static ComponentType<ChunkStore, BlockMountComponent> getComponentType() {
class="kw">return MountPlugin.getInstance().getBlockMountComponentType();
}
class="kw">public BlockMountComponent() {
}
class="kw">public BlockMountComponent(BlockMountType var1, Vector3i var2, BlockType var3, int var4) {
this.type = var1;
this.blockPos = var2;
this.expectedBlockType = var3;
this.expectedRotation = var4;
}
class="kw">public BlockMountType getType() {
class="kw">return this.type;
}
class="kw">public Vector3i getBlockPos() {
class="kw">return this.blockPos;
}
class="kw">public BlockType getExpectedBlockType() {
class="kw">return this.expectedBlockType;
}
class="kw">public int getExpectedRotation() {
class="kw">return this.expectedRotation;
}
class="kw">public boolean isDead() {
this.clean();
class="kw">return this.entitiesByMountPoint.isEmpty();
}
class="kw">private void clean() {
this.entitiesByMountPoint.values().removeIf(var0 -> !var0.isValid());
this.mountPointByEntity.keySet().removeIf(var0 -> !var0.isValid());
}
class="kw">public void putSeatedEntity(@Nonnull BlockMountPoint var1, @Nonnull Ref<EntityStore> var2) {
this.entitiesByMountPoint.put(var1, var2);
this.mountPointByEntity.put(var2, var1);
}
class="kw">public void removeSeatedEntity(@Nonnull Ref<EntityStore> var1) {
BlockMountPoint var2 = this.mountPointByEntity.remove(var1);
if (var2 != null) {
this.entitiesByMountPoint.remove(var2);
}
}
@Nullable
class="kw">public BlockMountPoint getSeatBlockBySeatedEntity(Ref<EntityStore> var1) {
class="kw">return this.mountPointByEntity.get(var1);
}
@Nonnull
class="kw">public Collection<? class="kw">extends Ref<EntityStore>> getSeatedEntities() {
class="kw">return this.entitiesByMountPoint.values();
}
@Nullable
class="kw">public BlockMountPoint findAvailableSeat(@Nonnull Vector3i var1, @Nonnull BlockMountPoint[] var2, @Nonnull Vector3d var3) {
this.clean();
double var4 = Double.MAX_VALUE;
BlockMountPoint var6 = null;
for (BlockMountPoint var10 : var2) {
if (!this.entitiesByMountPoint.containsKey(var10)) {
Vector3d var11 = var10.computeWorldSpacePosition(var1);
double var12 = var3.distanceSquared(var11);
if (var12 < var4) {
var4 = var12;
var6 = var10;
}
}
}
class="kw">return var6;
}
@Nonnull
@Override
class="kw">public Component<ChunkStore> clone() {
BlockMountComponent var1 = new BlockMountComponent();
var1.type = this.type;
var1.blockPos = this.blockPos;
var1.expectedBlockType = this.expectedBlockType;
var1.expectedRotation = this.expectedRotation;
var1.entitiesByMountPoint = new Object2ReferenceOpenHashMap(this.entitiesByMountPoint);
var1.mountPointByEntity = new Reference2ObjectOpenHashMap(this.mountPointByEntity);
class="kw">return var1;
}
}