BlockEntitySystems class

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

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

Поля (43)

МодификаторыТипИмя
final HytaleLogger LOGGER
private final Archetype<EntityStore> archetype
private final ComponentType<EntityStore, BlockEntity> blockEntityComponentType
private final ComponentType<EntityStore, BlockEntity> blockEntityComponentType
private final ComponentType<EntityStore, BlockEntity> blockEntityComponentType
private final ComponentType<EntityStore, BlockEntity> blockEntityComponentType
private final ComponentType<EntityStore, EntityScaleComponent> entityScaleComponentType
private final Query<EntityStore> query
private final Query<EntityStore> query
private final ComponentType<EntityStore, TransformComponent> transformComponentType
private final ComponentType<EntityStore, TransformComponent> transformComponentType
BoundingBox var10
var10
var10
var10
EntityScaleComponent var10
SimplePhysicsProvider var11
boolean var11
HeadRotation var4
String var4
BlockEntity var4
TransformComponent var5
int var5
TransformComponent var5
Rotation3f var6
EntityTrackerSystems.Visible var6
BlockUpdate var6
EntityScaleComponent var6
TransformComponent var6
TransformComponent var7
BlockEntity var7
float var7
BlockEntity var7
Rotation3f var8
float var8
var8
Vector3d var8
Velocity var8
BlockEntity var9
boolean var9
var9
Rotation3fc var9
private final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType

Методы (25)

МодификаторыВозвратСигнатура
public BlockEntitySetupSystempublic BlockEntitySetupSystem(ComponentType<EntityStore, BlockEntity> var1)
public BlockEntityTrackerSystempublic BlockEntityTrackerSystem(ComponentType<EntityStore, EntityTrackerSystems.Visible> var1, ComponentType<EntityStore, BlockEntity> var2)
public PositionMigrationSystempublic PositionMigrationSystem(@Nonnull ComponentType<EntityStore, BlockEntity> var1, @Nonnull ComponentType<EntityStore, TransformComponent> var2, @Nonnull ComponentType<EntityStore, EntityScaleComponent> var3)
public Tickingpublic Ticking(@Nonnull ComponentType<EntityStore, BlockEntity> var1)
public SystemGroup<EntityStore> getGrouppublic SystemGroup<EntityStore> getGroup()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
if if(var4 != null)
if if(var5 != null)
if if(var10 == null)
if if(var7 != null)
if if(var10 != null)
if if(var11 || var9)
if if(var5 == Integer.MIN_VALUE)
if if(var6 != null)
public boolean isParallelpublic boolean isParallel(int var1, int var2)
public void onEntityAddpublic void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3)
public void onEntityAddpublic void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3)
public void onEntityRemovedpublic void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3)
public void onEntityRemovedpublic void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3)
private static void queueUpdatesForprivate static void queueUpdatesFor(Ref<EntityStore> var0, @Nonnull BlockEntity var1, @Nonnull Map<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> var2, float var3)
public void tickpublic void tick(float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)
public void tickpublic void tick(float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)

Исходный код

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

class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.DisableProcessingAssert;
class="kw">import com.hypixel.hytale.component.Holder;
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.component.SystemGroup;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.HolderSystem;
class="kw">import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.math.shape.Box;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Rotation3fc;
class="kw">import com.hypixel.hytale.protocol.BlockUpdate;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.entity.entities.BlockEntity;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.EntityScaleComponent;
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.modules.entity.tracker.EntityTrackerSystems;
class="kw">import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId;
class="kw">import com.hypixel.hytale.server.core.modules.physics.SimplePhysicsProvider;
class="kw">import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.Map;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class BlockEntitySystems {
   class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();

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

   class="kw">public class="kw">static class BlockEntitySetupSystem class="kw">extends HolderSystem<EntityStore> {
      class="kw">private class="kw">final ComponentType<EntityStore, BlockEntity> blockEntityComponentType;

      class="kw">public BlockEntitySetupSystem(ComponentType<EntityStore, BlockEntity> var1) {
         this.blockEntityComponentType = var1;
      }

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         if (!var1.getArchetype().contains(NetworkId.getComponentType())) {
            var1.addComponent(NetworkId.getComponentType(), new NetworkId(var3.getExternalData().takeNextNetworkId()));
         }

         HeadRotation var4 = var1.getComponent(HeadRotation.getComponentType());
         if (var4 != null) {
            TransformComponent var5 = var1.getComponent(TransformComponent.getComponentType());
            if (var5 != null) {
               Rotation3f var6 = var4.getRotation();
               var5.getRotation().set(var6.pitch(), var6.yaw(), var6.roll());
            }

            var1.removeComponent(HeadRotation.getComponentType());
         }

         BlockEntity var9 = var1.getComponent(this.blockEntityComponentType);
         BoundingBox var10;
         if (!var1.getArchetype().contains(BoundingBox.getComponentType())) {
            var10 = var9.createBoundingBoxComponent();
            if (var10 == null) {
               BlockEntitySystems.LOGGER
                  .at(Level.SEVERE)
                  .log("Bounding box could not be initialized properly, defaulting to 1x1x1 dimensions for Block Entity bounding box");
               var10 = new BoundingBox(Box.horizontallyCentered(1.0, 1.0, 1.0));
            }

            var1.putComponent(BoundingBox.getComponentType(), var10);
         } else {
            var10 = var1.getComponent(BoundingBox.getComponentType());
         }

         TransformComponent var7 = var1.getComponent(TransformComponent.getComponentType());
         if (var7 != null) {
            Rotation3f var8 = var7.getRotation();
            var10.applyRotation(var8.pitch(), var8.yaw(), var8.roll());
         }

         var1.putComponent(BoundingBox.getComponentType(), var10);
         SimplePhysicsProvider var11 = var9.initPhysics(var10);
         var11.setMoveOutOfSolid(false);
      }

      @Override
      class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
      }

      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.blockEntityComponentType;
      }
   }

   class="kw">public class="kw">static class BlockEntityTrackerSystem class="kw">extends EntityTickingSystem<EntityStore> {
      class="kw">private class="kw">final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType;
      class="kw">private class="kw">final ComponentType<EntityStore, BlockEntity> blockEntityComponentType;
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query;

      class="kw">public BlockEntityTrackerSystem(ComponentType<EntityStore, EntityTrackerSystems.Visible> var1, ComponentType<EntityStore, BlockEntity> var2) {
         this.visibleComponentType = var1;
         this.blockEntityComponentType = var2;
         this.query = Query.and(var1, var2);
      }

      @Nullable
      @Override
      class="kw">public SystemGroup<EntityStore> getGroup() {
         class="kw">return EntityTrackerSystems.QUEUE_UPDATE_GROUP;
      }

      @Nonnull
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.query;
      }

      @Override
      class="kw">public boolean isParallel(int var1, int var2) {
         class="kw">return EntityTickingSystem.maybeUseParallel(var1, var2);
      }

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         EntityTrackerSystems.Visible var6 = var3.getComponent(var2, this.visibleComponentType);
         BlockEntity var7 = var3.getComponent(var2, this.blockEntityComponentType);
         assert var7 != null;
         float var8 = 1.0F;
         boolean var9 = false;
         EntityScaleComponent var10 = var3.getComponent(var2, EntityScaleComponent.getComponentType());
         if (var10 != null) {
            var8 = var10.getScale();
            var9 = var10.consumeNetworkOutdated();
         }

         boolean var11 = var7.consumeBlockIdNetworkOutdated();
         if (var11 || var9) {
            queueUpdatesFor(var3.getReferenceTo(var2), var7, var6.visibleTo, var8);
         } else if (!var6.newlyVisibleTo.isEmpty()) {
            queueUpdatesFor(var3.getReferenceTo(var2), var7, var6.newlyVisibleTo, var8);
         }
      }

      class="kw">private class="kw">static void queueUpdatesFor(
         Ref<EntityStore> var0, @Nonnull BlockEntity var1, @Nonnull Map<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> var2, float var3
      ) {
         String var4 = var1.getBlockTypeKey();
         int var5 = BlockType.getAssetMap().getIndex(var4);
         if (var5 == Integer.MIN_VALUE) {
            BlockEntitySystems.LOGGER.at(Level.WARNING).log("Skipping block entity update for unknown block type key: %s", var4);
         } else {
            BlockUpdate var6 = new BlockUpdate(var5, var3);

            for (EntityTrackerSystems.EntityViewer var8 : var2.values()) {
               var8.queueUpdate(var0, var6);
            }
         }
      }
   }

   class="kw">public class="kw">static class PositionMigrationSystem class="kw">extends HolderSystem<EntityStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, BlockEntity> blockEntityComponentType;
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, TransformComponent> transformComponentType;
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, EntityScaleComponent> entityScaleComponentType;
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query;

      class="kw">public PositionMigrationSystem(
         @Nonnull ComponentType<EntityStore, BlockEntity> var1,
         @Nonnull ComponentType<EntityStore, TransformComponent> var2,
         @Nonnull ComponentType<EntityStore, EntityScaleComponent> var3
      ) {
         this.blockEntityComponentType = var1;
         this.transformComponentType = var2;
         this.entityScaleComponentType = var3;
         this.query = Query.and(var1, var2);
      }

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         BlockEntity var4 = var1.getComponent(this.blockEntityComponentType);
         TransformComponent var5 = var1.getComponent(this.transformComponentType);
         EntityScaleComponent var6 = var1.getComponent(this.entityScaleComponentType);
         assert var5 != null;
         assert var4 != null;
         if (var4.consumeOutdatedAnchor()) {
            float var7 = var6 != null ? var6.getScale() : 2.0F;
            if (var6 != null) {
               var6.setScale(var7 / 2.0F);
            }

            Vector3d var8 = var5.getPosition();
            Rotation3fc var9 = var5.getRotation();
            var8.add(var9.transform(new Vector3d(0.0, var7 / 4.0F - 0.5, 0.0)));
            var8.add(0.0, 0.5, 0.0);
         }
      }

      @Override
      class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
      }

      @Nonnull
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.query;
      }
   }

   class="kw">public class="kw">static class Ticking class="kw">extends EntityTickingSystem<EntityStore> class="kw">implements DisableProcessingAssert {
      class="kw">private class="kw">final ComponentType<EntityStore, TransformComponent> transformComponentType = TransformComponent.getComponentType();
      class="kw">private class="kw">final ComponentType<EntityStore, BlockEntity> blockEntityComponentType;
      class="kw">private class="kw">final Archetype<EntityStore> archetype;

      class="kw">public Ticking(@Nonnull ComponentType<EntityStore, BlockEntity> var1) {
         this.blockEntityComponentType = var1;
         this.archetype = Archetype.of(this.transformComponentType, var1, Velocity.getComponentType());
      }

      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.archetype;
      }

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         TransformComponent var6 = var3.getComponent(var2, this.transformComponentType);
         assert var6 != null;
         BlockEntity var7 = var3.getComponent(var2, this.blockEntityComponentType);
         assert var7 != null;
         Velocity var8 = var3.getComponent(var2, Velocity.getComponentType());
         assert var8 != null;

         try {
            var7.getSimplePhysicsProvider().tick(var1, var8, var4.getExternalData().getWorld(), var6, var3.getReferenceTo(var2), var5);
         } catch (Throwable var10) {
            ((HytaleLogger.Api)BlockEntitySystems.LOGGER.at(Level.SEVERE).withCause(var10)).log("Exception while ticking entity. Removing entity %s", var7);
            var5.removeEntity(var3.getReferenceTo(var2), RemoveReason.REMOVE);
         }
      }
   }
}