Entity class

Пакет: com.hypixel.hytale.server.core.entity

Файл: com/hypixel/hytale/server/core/entity/Entity.java

implements: Component<EntityStore>

Поля (25)

МодификаторыТипИмя
public static final String DEATH
public static final String DESPAWN
public static final String FLY_SUFFIX
public static final String HURT
public static final String SWIM_SUFFIX
Dirty var1
String var1
int var1
DirectDecodeCodec var1
Holder var1
IEventDispatcher var2
Entity var2
Function var2
ComponentType var2
String var2
String var2
BsonDocument var3
Archetype var3
Entity var4
ComponentType var5
Component var6
Holder var7
DirectDecodeCodec var8
TransformComponent var9
Store var9

Методы (28)

МодификаторыВозвратСигнатура
public DefaultAnimationspublic DefaultAnimations()
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Entity is already in a world! " + this)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Entity is already not in a world! " + this)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Entity already has a valid EntityReference: " + this.reference + " new reference " + var1)
abstract for for(int var4 = var3.getMinIndex()
public static String[] getDeathAnimationIdspublic static String[] getDeathAnimationIds(@Nonnull MovementStates var0, @Nonnull DamageCause var1)
public static String[] getHurtAnimationIdspublic static String[] getHurtAnimationIds(@Nonnull MovementStates var0, @Nonnull DamageCause var1)
if if(var1 != null)
if if(this.world != null)
if if(this.networkId == -1)
if if(this.world == null)
if if(this == var1)
if if(this.networkId != var2.networkId)
if if(var5 != null)
if if(this instanceof Player)
if if(var8 == null)
if if(var0.swimming)
if if(var0.swimming)
public boolean isCollidableboolean isCollidable()
public boolean isHiddenFromLivingEntityboolean isHiddenFromLivingEntity(@Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3)
public void loadIntoWorldvoid loadIntoWorld(@Nonnull World var1)
public boolean removeboolean remove()
public void setLegacyUUIDvoid setLegacyUUID(@Nullable UUID var1)
public void setReferencevoid setReference(@Nonnull Ref<EntityStore> var1)
abstract this this()
public Holder<EntityStore> toHolderHolder<EntityStore> toHolder()
public void unloadFromWorldvoid unloadFromWorld()
public boolean wasRemovedboolean wasRemoved()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.entity;

class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.DirectDecodeCodec;
class="kw">import com.hypixel.hytale.codec.ExtraInfo;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.common.util.DebugFlags;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.NonSerialized;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.event.IEventDispatcher;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.protocol.MovementStates;
class="kw">import com.hypixel.hytale.server.core.HytaleServer;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.event.events.entity.EntityRemoveEvent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DamageCause;
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.Arrays;
class="kw">import java.util.UUID;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import java.util.concurrent.atomic.AtomicBoolean;
class="kw">import java.util.function.Function;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.bson.BsonDocument;

class="kw">public class="kw">abstract class Entity class="kw">implements Component<EntityStore> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
   class="kw">public class="kw">static class="kw">final int VERSION = 5;
   @Nonnull
   class="kw">public class="kw">static class="kw">final KeyedCodec<String> DISPLAY_NAME = new KeyedCodec<>("DisplayName", Codec.STRING);
   @Nonnull
   class="kw">public class="kw">static class="kw">final KeyedCodec<UUID> UUID = new KeyedCodec<>("UUID", Codec.UUID_BINARY);
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<Entity> CODEC = BuilderCodec.abstractBuilder(Entity.class)
      .legacyVersioned()
      .codecVersion(5)
      .append(DISPLAY_NAME, (var0, var1) -> var0.legacyDisplayName = var1, var0 -> var0.legacyDisplayName)
      .add()
      .append(UUID, (var0, var1) -> var0.legacyUuid = var1, var0 -> var0.legacyUuid)
      .add()
      .build();
   class="kw">public class="kw">static class="kw">final int UNASSIGNED_ID = -1;
   class="kw">protected int networkId = -1;
   @Nullable
   class="kw">protected UUID legacyUuid;
   @Nullable
   class="kw">protected World world;
   @Nullable
   class="kw">protected Ref<EntityStore> reference;
   @Deprecated(forRemoval = true)
   class="kw">protected String legacyDisplayName;
   @Nonnull
   class="kw">protected class="kw">final AtomicBoolean wasRemoved = new AtomicBoolean();
   @Nullable
   class="kw">protected Throwable removedBy;

   @Deprecated
   class="kw">public Entity(@Nullable World var1) {
      this();
      this.networkId = var1 != null ? var1.getEntityStore().takeNextNetworkId() : -1;
      this.world = var1;
   }

   class="kw">public Entity() {
   }

   @Deprecated(forRemoval = true)
   class="kw">public void markNeedsSave() {
      if (this.reference != null && this.reference.isValid() && this.world != null && this.world.isInThread()) {
         Dirty var1 = this.reference.getStore().getComponent(this.reference, Dirty.getComponentType());
         if (var1 != null) {
            var1.markDirty();
         }
      }
   }

   class="kw">public void setLegacyUUID(@Nullable UUID var1) {
      this.legacyUuid = var1;
   }

   class="kw">public boolean remove() {
      this.world.debugAssertInTickingThread();
      if (this.wasRemoved.getAndSet(true)) {
         class="kw">return false;
      }

      this.removedBy = DebugFlags.CAPTURE_THROWABLES ? new Throwable() : null;

      try {
         String var1 = this.world != null ? this.world.getName() : null;
         IEventDispatcher var2 = HytaleServer.get().getEventBus().dispatchFor(EntityRemoveEvent.class, var1);
         if (var2.hasListener()) {
            var2.dispatch(new EntityRemoveEvent(this));
         }

         if (this.reference.isValid()) {
            this.world.getEntityStore().getStore().removeEntity(this.reference, RemoveReason.REMOVE);
         }
      } catch (Throwable var3) {
         this.wasRemoved.set(false);
      }

      class="kw">return true;
   }

   class="kw">public void loadIntoWorld(@Nonnull World var1) {
      if (this.world != null) {
         throw new IllegalArgumentException("Entity is already in a world! " + this);
      }

      this.world = var1;
      if (this.networkId == -1) {
         this.networkId = var1.getEntityStore().takeNextNetworkId();
      }
   }

   class="kw">public void unloadFromWorld() {
      if (this.world == null) {
         throw new IllegalArgumentException("Entity is already not in a world! " + this);
      }

      this.networkId = -1;
      this.world = null;
   }

   @Deprecated(forRemoval = true)
   class="kw">public int getNetworkId() {
      class="kw">return this.networkId;
   }

   @Deprecated(forRemoval = true)
   class="kw">public String getLegacyDisplayName() {
      class="kw">return this.legacyDisplayName;
   }

   @Nullable
   @Deprecated(forRemoval = true)
   class="kw">public UUID getUuid() {
      class="kw">return this.legacyUuid;
   }

   @Deprecated
   class="kw">public void moveTo(@Nonnull Ref<EntityStore> var1, double var2, double var4, double var6, @Nonnull ComponentAccessor<EntityStore> var8) {
      TransformComponent var9 = var8.getComponent(var1, TransformComponent.getComponentType());
      assert var9 != null;
      var9.getPosition().set(var2, var4, var6);
   }

   @Nullable
   class="kw">public World getWorld() {
      class="kw">return this.world;
   }

   class="kw">public boolean wasRemoved() {
      class="kw">return this.wasRemoved.get();
   }

   class="kw">public boolean isCollidable() {
      class="kw">return true;
   }

   @Override
   class="kw">public int hashCode() {
      int var1 = this.networkId;
      class="kw">return 31 * var1 + (this.world != null ? this.world.hashCode() : 0);
   }

   @Override
   class="kw">public boolean equals(@Nullable Object var1) {
      if (this == var1) {
         class="kw">return true;
      }

      if (var1 != null && this.getClass() == var1.getClass()) {
         Entity var2 = (Entity)var1;
         if (this.networkId != var2.networkId) {
            class="kw">return false;
         } else {
            class="kw">return this.world != null ? this.world.equals(var2.world) : var2.world == null;
         }
      } else {
         class="kw">return false;
      }
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "Entity{id="
         + this.networkId
         + ", uuid="
         + this.legacyUuid
         + ", reference='"
         + this.reference
         + "', world="
         + (this.world != null ? this.world.getName() : null)
         + ", displayName='"
         + this.legacyDisplayName
         + "', wasRemoved='"
         + this.wasRemoved
         + "', removedBy='"
         + (this.removedBy != null ? this.removedBy + "\n" + Arrays.toString(this.removedBy.getStackTrace()) : null)
         + "'}";
   }

   class="kw">public boolean isHiddenFromLivingEntity(@Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      class="kw">return false;
   }

   class="kw">public void setReference(@Nonnull Ref<EntityStore> var1) {
      if (this.reference != null && this.reference.isValid()) {
         throw new IllegalArgumentException("Entity already has a valid EntityReference: " + this.reference + " new reference " + var1);
      }

      this.reference = var1;
   }

   @Nullable
   class="kw">public Ref<EntityStore> getReference() {
      class="kw">return this.reference;
   }

   @Deprecated
   class="kw">public void clearReference() {
      this.reference = null;
   }

   @Override
   class="kw">public Component<EntityStore> clone() {
      DirectDecodeCodec var1 = EntityModule.get().getCodec((Class<Entity>)this.getClass());
      Function var2 = EntityModule.get().getConstructor((Class<Entity>)this.getClass());
      BsonDocument var3 = var1.encode(this, ExtraInfo.THREAD_LOCAL.get()).asDocument();
      Entity var4 = var2.apply(null);
      var1.decode(var3, var4, ExtraInfo.THREAD_LOCAL.get());
      class="kw">return var4;
   }

   class="kw">public Holder<EntityStore> toHolder() {
      if (this.reference != null && this.reference.isValid() && this.world != null) {
         if (!this.world.isInThread()) {
            class="kw">return CompletableFuture.supplyAsync(this::toHolder, this.world).join();
         }

         Holder var7 = EntityStore.REGISTRY.newHolder();
         Store var9 = this.world.getEntityStore().getStore();
         Archetype var3 = var9.getArchetype(this.reference);

         for (int var4 = var3.getMinIndex(); var4 < var3.length(); var4++) {
            ComponentType var5 = var3.get(var4);
            if (var5 != null) {
               Component var6 = var9.getComponent(this.reference, var5);
               assert var6 != null;
               var7.addComponent(var5, var6);
            }
         }

         class="kw">return var7;
      } else {
         Holder var1 = EntityStore.REGISTRY.newHolder();
         if (this class="kw">instanceof Player) {
            var1.addComponent(Player.getComponentType(), (Player)this);
         } else {
            ComponentType var2 = EntityModule.get().getComponentType((Class<? class="kw">extends Entity>)this.getClass());
            var1.addComponent(var2, this);
         }

         DirectDecodeCodec var8 = EntityModule.get().getCodec((Class<? class="kw">extends Entity>)this.getClass());
         if (var8 == null) {
            var1.addComponent(EntityStore.REGISTRY.getNonSerializedComponentType(), NonSerialized.get());
         }

         class="kw">return var1;
      }
   }

   class="kw">public class="kw">static class DefaultAnimations {
      @Nonnull
      class="kw">public class="kw">static class="kw">final String DEATH = "Death";
      @Nonnull
      class="kw">public class="kw">static class="kw">final String HURT = "Hurt";
      @Nonnull
      class="kw">public class="kw">static class="kw">final String DESPAWN = "Despawn";
      @Nonnull
      class="kw">public class="kw">static class="kw">final String SWIM_SUFFIX = "Swim";
      @Nonnull
      class="kw">public class="kw">static class="kw">final String FLY_SUFFIX = "Fly";

      class="kw">public DefaultAnimations() {
      }

      @Nonnull
      class="kw">public class="kw">static String[] getHurtAnimationIds(@Nonnull MovementStates var0, @Nonnull DamageCause var1) {
         String var2 = var1.getAnimationId();
         if (var0.swimming) {
            class="kw">return new String[]{var2 + "Swim", var2, "Hurt"};
         } else {
            class="kw">return var0.flying ? new String[]{var2 + "Fly", var2, "Hurt"} : new String[]{var2, "Hurt"};
         }
      }

      @Nonnull
      class="kw">public class="kw">static String[] getDeathAnimationIds(@Nonnull MovementStates var0, @Nonnull DamageCause var1) {
         String var2 = var1.getDeathAnimationId();
         if (var0.swimming) {
            class="kw">return new String[]{var2 + "Swim", var2, "Death"};
         } else {
            class="kw">return var0.flying ? new String[]{var2 + "Fly", var2, "Death"} : new String[]{var2, "Death"};
         }
      }
   }
}