FallingBlockTickingSystem class

Пакет: com.hypixel.hytale.builtin.fallingblocks

Файл: com/hypixel/hytale/builtin/fallingblocks/FallingBlockTickingSystem.java

extends: EntityTickingSystem<EntityStore>

Поля (17)

МодификаторыТипИмя
BoundingBox var10
BlockEntity var11
World var12
Vector3d var13
Box var14
SimplePhysicsProvider var15
Ref var16
String var17
BlockType var18
Rotation3f var19
RotationTuple var20
FallingBlockSettings var21
Ref var22
FallingBlock var6
Velocity var7
TransformComponent var8
PhysicsValues var9

Исходный код

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

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.Ref;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
class="kw">import com.hypixel.hytale.math.shape.Box;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.protocol.BlockMaterial;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.fallingblocks.FallingBlockSettings;
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.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.item.ItemPrePhysicsSystem;
class="kw">import com.hypixel.hytale.server.core.modules.physics.SimplePhysicsProvider;
class="kw">import com.hypixel.hytale.server.core.modules.physics.component.PhysicsValues;
class="kw">import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
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 javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;

class="kw">public class FallingBlockTickingSystem class="kw">extends EntityTickingSystem<EntityStore> {
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, FallingBlock> fallingBlockComponentType;
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, TransformComponent> transformComponentType;
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, Velocity> velocityComponentType;
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, PhysicsValues> physicsValuesComponentType;
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, BoundingBox> boundingBoxComponentType;
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, BlockEntity> blockEntityComponentType;
   @Nonnull
   class="kw">private class="kw">final Query<EntityStore> query;

   class="kw">public FallingBlockTickingSystem(
      @Nonnull ComponentType<EntityStore, FallingBlock> var1,
      @Nonnull ComponentType<EntityStore, TransformComponent> var2,
      @Nonnull ComponentType<EntityStore, Velocity> var3,
      @Nonnull ComponentType<EntityStore, PhysicsValues> var4,
      @Nonnull ComponentType<EntityStore, BoundingBox> var5,
      @Nonnull ComponentType<EntityStore, BlockEntity> var6
   ) {
      this.fallingBlockComponentType = var1;
      this.transformComponentType = var2;
      this.velocityComponentType = var3;
      this.physicsValuesComponentType = var4;
      this.boundingBoxComponentType = var5;
      this.blockEntityComponentType = var6;
      this.query = Query.and(var1, var2, var3, var4, var5, var6);
   }

   @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) {
      FallingBlock var6 = var3.getComponent(var2, this.fallingBlockComponentType);
      assert var6 != null;
      Velocity var7 = var3.getComponent(var2, this.velocityComponentType);
      assert var7 != null;
      TransformComponent var8 = var3.getComponent(var2, this.transformComponentType);
      assert var8 != null;
      PhysicsValues var9 = var3.getComponent(var2, this.physicsValuesComponentType);
      assert var9 != null;
      BoundingBox var10 = var3.getComponent(var2, this.boundingBoxComponentType);
      assert var10 != null;
      BlockEntity var11 = var3.getComponent(var2, this.blockEntityComponentType);
      assert var11 != null;
      World var12 = var5.getExternalData().getWorld();
      Vector3d var13 = var8.getPosition();
      Box var14 = var10.getBoundingBox();
      ItemPrePhysicsSystem.applyGravity(var1, var14, var9, var13, var7);
      SimplePhysicsProvider var15 = var11.getSimplePhysicsProvider();
      if (var15.isOnGround()) {
         Ref var16 = var12.getChunkStore().getChunkSectionReferenceAtBlock(MathUtil.floor(var13.x), MathUtil.floor(var13.y), MathUtil.floor(var13.z));
         if (var16 != null && var16.isValid()) {
            String var17 = var11.getBlockTypeKey();
            BlockType var18 = BlockType.getAssetMap().getAsset(var17);
            if (var18 != null && var18.getMaterial() != BlockMaterial.Empty) {
               Rotation3f var19 = var8.getRotation();
               RotationTuple var20 = RotationTuple.of(
                  Rotation.closestOfDegrees((float)Math.toDegrees(var19.y - (float) Math.PI)),
                  Rotation.closestOfDegrees((float)Math.toDegrees(var19.x)),
                  Rotation.closestOfDegrees((float)Math.toDegrees(var19.z))
               );
               FallingBlockSettings var21 = var18.getFallingBlockSettings();
               Ref var22 = var3.getReferenceTo(var2);
               if (var21 != null && var21.getImpact() != null) {
                  var21.getImpact().apply(var16, var12, var18, var13, var20, var4, var22, var5);
               } else {
                  PlaceFallingBlockImpact.placeFallingBlock(var16, var12, var18, var13, var20, var4, var22, var5);
               }
            }

            var5.removeEntity(var3.getReferenceTo(var2), RemoveReason.REMOVE);
         }
      }
   }
}