EntityTransformSnapshot class
Пакет: com.hypixel.hytale.builtin.buildertools.snapshot
Файл: com/hypixel/hytale/builtin/buildertools/snapshot/EntityTransformSnapshot.java
implements: EntitySnapshot<EntityTransformSnapshot>
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
|
TransformComponent |
var2 |
|
TransformComponent |
var3 |
|
HeadRotation |
var3 |
|
BoundingBox |
var3 |
|
HeadRotation |
var4 |
|
TransformComponent |
var4 |
|
Rotation3f |
var4 |
|
EntityTransformSnapshot |
var5 |
|
HeadRotation |
var6 |
Методы (10)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
void |
applyTransformvoid applyTransform(@Nonnull ComponentAccessor<EntityStore> var1) |
|
|
if if(this.ref == var1) |
|
|
if if(var2 != null) |
|
|
if if(var3 != null && this.headRotation != null) |
|
|
if if(var6 != null && this.headRotation != null) |
|
|
if if(var3 != null) |
public |
EntityTransformSnapshot |
restoreEntityEntityTransformSnapshot restoreEntity(@Nonnull PlayerRef var1, @Nonnull World var2, @Nonnull ComponentAccessor<EntityStore> var3) |
static |
void |
syncBoundingBoxvoid syncBoundingBox(@Nonnull Ref<EntityStore> var0, @Nonnull TransformComponent var1, @Nonnull ComponentAccessor<EntityStore> var2) |
abstract |
|
syncBoundingBox syncBoundingBox(this.ref, var2, var1) |
abstract |
|
syncBoundingBox syncBoundingBox(this.ref, var4, var3) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.buildertools.snapshot;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
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.Transform;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class EntityTransformSnapshot class="kw">implements EntitySnapshot<EntityTransformSnapshot> {
@Nonnull
class="kw">private Ref<EntityStore> ref;
@Nonnull
class="kw">private class="kw">final Transform transform;
@Nullable
class="kw">private class="kw">final Rotation3f headRotation;
class="kw">public EntityTransformSnapshot(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
this.ref = var1;
TransformComponent var3 = var2.getComponent(var1, TransformComponent.getComponentType());
assert var3 != null;
HeadRotation var4 = var2.getComponent(var1, HeadRotation.getComponentType());
this.transform = new Transform(var3.getTransform());
this.headRotation = var4 != null ? new Rotation3f(var4.getRotation()) : null;
}
@Override
class="kw">public void updateEntityRef(@Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2) {
if (this.ref == var1) {
this.ref = var2;
}
}
class="kw">public void applyTransform(@Nonnull ComponentAccessor<EntityStore> var1) {
if (this.ref.isValid()) {
TransformComponent var2 = var1.getComponent(this.ref, TransformComponent.getComponentType());
if (var2 != null) {
var2.setPosition(this.transform.getPosition());
var2.setRotation(this.transform.getRotation());
HeadRotation var3 = var1.getComponent(this.ref, HeadRotation.getComponentType());
if (var3 != null && this.headRotation != null) {
var3.setRotation(this.headRotation);
}
syncBoundingBox(this.ref, var2, var1);
}
}
}
class="kw">public EntityTransformSnapshot restoreEntity(@Nonnull PlayerRef var1, @Nonnull World var2, @Nonnull ComponentAccessor<EntityStore> var3) {
if (!this.ref.isValid()) {
class="kw">return null;
}
TransformComponent var4 = var3.getComponent(this.ref, TransformComponent.getComponentType());
assert var4 != null;
EntityTransformSnapshot var5 = new EntityTransformSnapshot(this.ref, var3);
var4.setPosition(this.transform.getPosition());
var4.setRotation(this.transform.getRotation());
HeadRotation var6 = var3.getComponent(this.ref, HeadRotation.getComponentType());
if (var6 != null && this.headRotation != null) {
var6.setRotation(this.headRotation);
}
syncBoundingBox(this.ref, var4, var3);
class="kw">return var5;
}
class="kw">private class="kw">static void syncBoundingBox(@Nonnull Ref<EntityStore> var0, @Nonnull TransformComponent var1, @Nonnull ComponentAccessor<EntityStore> var2) {
BoundingBox var3 = var2.getComponent(var0, BoundingBox.getComponentType());
if (var3 != null) {
Rotation3f var4 = var1.getRotation();
var3.applyRotation(var4.pitch(), var4.yaw(), var4.roll());
}
}
}