TransformComponent class
Пакет: com.hypixel.hytale.server.core.modules.entity.component
Файл: com/hypixel/hytale/server/core/modules/entity/component/TransformComponent.java
implements: Component<EntityStore>
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
double |
MOVEMENT_SAVE_THRESHOLD |
|
TransformComponent |
var1 |
|
double |
var2 |
|
float |
var2 |
|
ModelTransform |
var2 |
|
float |
var3 |
|
double |
var4 |
|
float |
var4 |
|
double |
var6 |
Методы (11)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
return new |
Transformreturn new Transform(this.position, this.rotation) |
static |
ComponentType<EntityStore, TransformComponent> |
getComponentTypeComponentType<EntityStore, TransformComponent> getComponentType() |
|
|
if if(this.lastPosition == null) |
|
|
if if(this.lastPosition == null) |
public |
boolean |
pollMovedEnoughToSaveboolean pollMovedEnoughToSave() |
public |
void |
seedLastSavedPositionvoid seedLastSavedPosition() |
public |
void |
setPositionvoid setPosition(@Nonnull Vector3dc var1) |
public |
void |
setRotationvoid setRotation(@Nonnull Rotation3f var1) |
public |
void |
setSectionLocationvoid setSectionLocation(@Nullable Ref<ChunkStore> var1) |
public |
void |
teleportPositionvoid teleportPosition(@Nonnull Vector3dc var1) |
public |
void |
teleportRotationvoid teleportRotation(@Nonnull Rotation3f var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.entity.component;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
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.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Rotation3fc;
class="kw">import com.hypixel.hytale.math.vector.Transform;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.protocol.Direction;
class="kw">import com.hypixel.hytale.protocol.ModelTransform;
class="kw">import com.hypixel.hytale.protocol.Position;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
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 com.hypixel.hytale.server.core.util.PositionUtil;
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 TransformComponent class="kw">implements Component<EntityStore> {
class="kw">private class="kw">static class="kw">final double MOVEMENT_SAVE_THRESHOLD = 2.25;
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<TransformComponent> CODEC = BuilderCodec.builder(TransformComponent.class, TransformComponent::new)
.append(new KeyedCodec<>("Position", Vector3dUtil.CODEC), (var0, var1) -> var0.position.set(var1), var0 -> var0.position)
.add()
.append(new KeyedCodec<>("Rotation", Rotation3f.CODEC), (var0, var1) -> var0.rotation.set(var1), var0 -> var0.rotation)
.add()
.build();
@Nonnull
class="kw">private class="kw">final Vector3d position = new Vector3d();
@Nonnull
class="kw">private class="kw">final Rotation3f rotation = new Rotation3f();
@Nonnull
class="kw">private class="kw">final ModelTransform sentTransform = new ModelTransform(new Position(), new Direction(), new Direction());
@Nullable
class="kw">private Vector3d lastPosition;
@Nullable
class="kw">private Ref<ChunkStore> sectionRef;
class="kw">public class="kw">static ComponentType<EntityStore, TransformComponent> getComponentType() {
class="kw">return EntityModule.get().getTransformComponentType();
}
class="kw">public TransformComponent() {
}
class="kw">public TransformComponent(@Nonnull Vector3dc var1, @Nonnull Rotation3fc var2) {
this.position.set(var1);
this.rotation.set(var2);
}
@Nonnull
class="kw">public Vector3d getPosition() {
class="kw">return this.position;
}
class="kw">public void setPosition(@Nonnull Vector3dc var1) {
this.position.set(var1);
}
class="kw">public void teleportPosition(@Nonnull Vector3dc var1) {
double var2 = var1.x();
if (!Double.isNaN(var2)) {
this.position.x = var2;
}
double var4 = var1.y();
if (!Double.isNaN(var4)) {
this.position.y = var4;
}
double var6 = var1.z();
if (!Double.isNaN(var6)) {
this.position.z = var6;
}
}
@Nonnull
class="kw">public Rotation3f getRotation() {
class="kw">return this.rotation;
}
class="kw">public void setRotation(@Nonnull Rotation3f var1) {
this.rotation.set(var1);
}
@Nonnull
class="kw">public Transform getTransform() {
class="kw">return new Transform(this.position, this.rotation);
}
class="kw">public void teleportRotation(@Nonnull Rotation3f var1) {
float var2 = var1.yaw();
if (!Float.isNaN(var2)) {
this.rotation.setYaw(var2);
}
float var3 = var1.pitch();
if (!Float.isNaN(var3)) {
this.rotation.setPitch(var3);
}
float var4 = var1.roll();
if (!Float.isNaN(var4)) {
this.rotation.setRoll(var4);
}
}
@Nonnull
class="kw">public ModelTransform getSentTransform() {
class="kw">return this.sentTransform;
}
@Nullable
class="kw">public Ref<ChunkStore> getSectionRef() {
class="kw">return this.sectionRef;
}
class="kw">public void setSectionLocation(@Nullable Ref<ChunkStore> var1) {
this.sectionRef = var1;
}
class="kw">public void seedLastSavedPosition() {
if (this.lastPosition == null) {
this.lastPosition = new Vector3d(this.position);
} else {
this.lastPosition.set(this.position);
}
}
class="kw">public boolean pollMovedEnoughToSave() {
if (this.lastPosition == null) {
this.lastPosition = new Vector3d(this.position);
class="kw">return true;
}
if (this.lastPosition.distanceSquared(this.position) < 2.25) {
class="kw">return false;
}
this.lastPosition.set(this.position);
class="kw">return true;
}
@Nonnull
class="kw">public TransformComponent clone() {
TransformComponent var1 = new TransformComponent(this.position, this.rotation);
ModelTransform var2 = var1.sentTransform;
PositionUtil.assign(var2.position, this.sentTransform.position);
PositionUtil.assign(var2.bodyOrientation, this.sentTransform.bodyOrientation);
PositionUtil.assign(var2.lookOrientation, this.sentTransform.lookOrientation);
class="kw">return var1;
}
}