EntitySettingsSnapshot class
Пакет: com.hypixel.hytale.builtin.buildertools.snapshot
Файл: com/hypixel/hytale/builtin/buildertools/snapshot/EntitySettingsSnapshot.java
implements: EntitySnapshot<EntitySettingsSnapshot>
Поля (13)
| Модификаторы | Тип | Имя |
|---|---|---|
|
DynamicLight |
var2 |
|
Archetype |
var2 |
|
HitboxCollisionConfig |
var2 |
|
DynamicLight |
var3 |
|
PersistentDynamicLight |
var3 |
|
Interactions |
var3 |
|
|
var3 |
|
Archetype |
var3 |
|
HitboxCollision |
var3 |
|
HitboxCollision |
var4 |
|
EntitySettingsSnapshot |
var4 |
|
Interactions |
var4 |
|
|
var4 |
Методы (16)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
void |
applyPickupStatevoid applyPickupState(@Nonnull Ref<EntityStore> var0, boolean var1, @Nonnull ComponentAccessor<EntityStore> var2) |
|
|
if if(this.ref == var1) |
|
|
if if(this.previousLight == null) |
|
|
if if(var2 != null) |
|
|
if if(var3 != null) |
|
|
if if(this.wasPickupEnabled) |
|
|
if if(var3 == null) |
|
|
if if(var1) |
|
|
if if(var4 == null) |
|
|
if if(this.previousCollisionConfigId == null) |
|
|
if if(var2 == null) |
|
|
if if(var3 != null) |
private |
void |
restoreCollisionvoid restoreCollision(@Nonnull ComponentAccessor<EntityStore> var1) |
public |
EntitySettingsSnapshot |
restoreEntityEntitySettingsSnapshot restoreEntity(@Nonnull PlayerRef var1, @Nonnull World var2, @Nonnull ComponentAccessor<EntityStore> var3) |
private |
void |
restoreLightvoid restoreLight(@Nonnull ComponentAccessor<EntityStore> var1) |
private |
void |
restorePickupvoid restorePickup(@Nonnull ComponentAccessor<EntityStore> var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.buildertools.snapshot;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.protocol.ColorLight;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.DynamicLight;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.Interactable;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PersistentDynamicLight;
class="kw">import com.hypixel.hytale.server.core.modules.entity.hitboxcollision.HitboxCollision;
class="kw">import com.hypixel.hytale.server.core.modules.entity.hitboxcollision.HitboxCollisionConfig;
class="kw">import com.hypixel.hytale.server.core.modules.entity.item.PreventPickup;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.Interactions;
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 java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class EntitySettingsSnapshot class="kw">implements EntitySnapshot<EntitySettingsSnapshot> {
@Nonnull
class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
@Nonnull
class="kw">private Ref<EntityStore> ref;
@Nullable
class="kw">private class="kw">final ColorLight previousLight;
class="kw">private class="kw">final boolean wasPickupEnabled;
@Nullable
class="kw">private class="kw">final String previousCollisionConfigId;
class="kw">public EntitySettingsSnapshot(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
this.ref = var1;
DynamicLight var3 = var2.getComponent(var1, DynamicLight.getComponentType());
this.previousLight = var3 != null ? new ColorLight(var3.getColorLight()) : null;
this.wasPickupEnabled = !var2.getArchetype(var1).contains(PreventPickup.getComponentType());
HitboxCollision var4 = var2.getComponent(var1, HitboxCollision.getComponentType());
this.previousCollisionConfigId = var4 != null ? var4.getHitboxCollisionConfigId() : 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 EntitySettingsSnapshot restoreEntity(@Nonnull PlayerRef var1, @Nonnull World var2, @Nonnull ComponentAccessor<EntityStore> var3) {
if (!this.ref.isValid()) {
class="kw">return null;
}
EntitySettingsSnapshot var4 = new EntitySettingsSnapshot(this.ref, var3);
this.restoreLight(var3);
this.restorePickup(var3);
this.restoreCollision(var3);
class="kw">return var4;
}
class="kw">private void restoreLight(@Nonnull ComponentAccessor<EntityStore> var1) {
if (this.previousLight == null) {
var1.tryRemoveComponent(this.ref, DynamicLight.getComponentType());
var1.tryRemoveComponent(this.ref, PersistentDynamicLight.getComponentType());
} else {
DynamicLight var2 = var1.getComponent(this.ref, DynamicLight.getComponentType());
if (var2 != null) {
var2.setColorLight(this.previousLight);
} else {
var1.addComponent(this.ref, DynamicLight.getComponentType(), new DynamicLight(this.previousLight));
}
PersistentDynamicLight var3 = var1.getComponent(this.ref, PersistentDynamicLight.getComponentType());
if (var3 != null) {
var3.setColorLight(this.previousLight);
} else {
var1.addComponent(this.ref, PersistentDynamicLight.getComponentType(), new PersistentDynamicLight(this.previousLight));
}
}
}
class="kw">private void restorePickup(@Nonnull ComponentAccessor<EntityStore> var1) {
Archetype var2 = var1.getArchetype(this.ref);
if (this.wasPickupEnabled) {
if (!var2.contains(Interactable.getComponentType())) {
var1.addComponent(this.ref, Interactable.getComponentType());
}
var1.tryRemoveComponent(this.ref, PreventPickup.getComponentType());
Interactions var3 = var1.getComponent(this.ref, Interactions.getComponentType());
if (var3 == null) {
var3 = new Interactions();
var1.addComponent(this.ref, Interactions.getComponentType(), var3);
}
var3.setInteractionId(InteractionType.Use, "*PickupItem");
var3.setInteractionHint("server.interactionHints.pickup");
} else {
var1.tryRemoveComponent(this.ref, Interactable.getComponentType());
var1.tryRemoveComponent(this.ref, Interactions.getComponentType());
if (!var2.contains(PreventPickup.getComponentType())) {
var1.addComponent(this.ref, PreventPickup.getComponentType());
}
}
}
class="kw">public class="kw">static void applyPickupState(@Nonnull Ref<EntityStore> var0, boolean var1, @Nonnull ComponentAccessor<EntityStore> var2) {
Archetype var3 = var2.getArchetype(var0);
if (var1) {
if (!var3.contains(Interactable.getComponentType())) {
var2.addComponent(var0, Interactable.getComponentType());
}
var2.tryRemoveComponent(var0, PreventPickup.getComponentType());
Interactions var4 = var2.getComponent(var0, Interactions.getComponentType());
if (var4 == null) {
var4 = new Interactions();
var2.addComponent(var0, Interactions.getComponentType(), var4);
}
var4.setInteractionId(InteractionType.Use, "*PickupItem");
var4.setInteractionHint("server.interactionHints.pickup");
} else {
var2.tryRemoveComponent(var0, Interactable.getComponentType());
var2.tryRemoveComponent(var0, Interactions.getComponentType());
if (!var3.contains(PreventPickup.getComponentType())) {
var2.addComponent(var0, PreventPickup.getComponentType());
}
}
}
class="kw">private void restoreCollision(@Nonnull ComponentAccessor<EntityStore> var1) {
if (this.previousCollisionConfigId == null) {
var1.tryRemoveComponent(this.ref, HitboxCollision.getComponentType());
} else {
HitboxCollisionConfig var2 = HitboxCollisionConfig.getAssetMap().getAsset(this.previousCollisionConfigId);
if (var2 == null) {
LOGGER.at(Level.FINE).log("Dropping HitboxCollision restore; config '%s' no longer exists", this.previousCollisionConfigId);
} else {
HitboxCollision var3 = var1.getComponent(this.ref, HitboxCollision.getComponentType());
if (var3 != null) {
var3.setHitboxCollisionConfig(var2);
} else {
var1.addComponent(this.ref, HitboxCollision.getComponentType(), new HitboxCollision(var2));
}
}
}
}
}