BlockEntity class

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

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

implements: Component<EntityStore>

Поля (11)

МодификаторыТипИмя
final int VERSION
BlockTypeAssetMap var1
boolean var1
BlockEntity var1
BlockType var2
Holder var3
BoundingBox var3
Vector3d var3
Box var4
BoundingBox var4
BoundingBox var5

Методы (14)

МодификаторыВозвратСигнатура
public void addVelocityvoid addVelocity(float var1, float var2, float var3)
public void addVelocityvoid addVelocity(@Nonnull Vector3d var1)
public boolean consumeBlockIdNetworkOutdatedboolean consumeBlockIdNetworkOutdated()
public boolean consumeOutdatedAnchorboolean consumeOutdatedAnchor()
public String getBlockTypeKeyString getBlockTypeKey()
static ComponentType<EntityStore, BlockEntity> getComponentTypeComponentType<EntityStore, BlockEntity> getComponentType()
if if(var2 instanceof BlockMigrationExtraInfo)
if if(this.blockTypeKey == null)
if if(var1 == null)
if if(var2 == null)
if if(var4 != null)
if if(this.shouldMoveOutdatedAnchor)
public void setBlockTypeKeyvoid setBlockTypeKey(String var1, @Nonnull Ref<EntityStore> var2, @Nonnull CommandBuffer<EntityStore> var3)
public void setBlockTypeKeyvoid setBlockTypeKey(String var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3)

Исходный код

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

class="kw">import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
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.Ref;
class="kw">import com.hypixel.hytale.math.shape.Box;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.projectile.config.Projectile;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.BlockMigrationExtraInfo;
class="kw">import com.hypixel.hytale.server.core.modules.entity.DespawnComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
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.physics.SimplePhysicsProvider;
class="kw">import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
class="kw">import com.hypixel.hytale.server.core.modules.time.TimeResource;
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">import org.joml.Vector3d;

class="kw">public class BlockEntity class="kw">implements Component<EntityStore> {
   class="kw">public class="kw">static class="kw">final int VERSION = 1;
   class="kw">public class="kw">static class="kw">final BuilderCodec<BlockEntity> CODEC = BuilderCodec.<BlockEntity>builder(BlockEntity.class, BlockEntity::new)
      .versioned()
      .codecVersion(1)
      .append(new KeyedCodec<>("BlockTypeKey", Codec.STRING), (var0, var1, var2) -> {
         var0.blockTypeKey = var1;
         if (var2 class="kw">instanceof BlockMigrationExtraInfo) {
            var0.blockTypeKey = ((BlockMigrationExtraInfo)var2).getBlockMigration().apply(var1);
         }
      }, (var0, var1) -> var0.blockTypeKey)
      .add()
      .afterDecode((var0, var1) -> {
         if (var1.getVersion() == 0) {
            var0.shouldMoveOutdatedAnchor = true;
         }
      })
      .build();
   class="kw">public class="kw">static class="kw">final int DEFAULT_DESPAWN_SECONDS = 120;
   class="kw">protected String blockTypeKey;
   class="kw">private boolean shouldMoveOutdatedAnchor;
   @Nonnull
   class="kw">private class="kw">transient SimplePhysicsProvider simplePhysicsProvider = new SimplePhysicsProvider();
   class="kw">private boolean isBlockIdNetworkOutdated;

   class="kw">protected BlockEntity() {
   }

   class="kw">public BlockEntity(String var1) {
      this.blockTypeKey = var1;
   }

   class="kw">public class="kw">static ComponentType<EntityStore, BlockEntity> getComponentType() {
      class="kw">return EntityModule.get().getBlockEntityComponentType();
   }

   @Nonnull
   class="kw">public class="kw">static Holder<EntityStore> assembleDefaultBlockEntity(@Nonnull TimeResource var0, String var1, @Nonnull Vector3d var2) {
      Holder var3 = EntityStore.REGISTRY.newHolder();
      var3.addComponent(getComponentType(), new BlockEntity(var1));
      var3.addComponent(DespawnComponent.getComponentType(), DespawnComponent.despawnInSeconds(var0, 120));
      var3.addComponent(TransformComponent.getComponentType(), new TransformComponent(new Vector3d(var2), Rotation3f.IDENTITY));
      var3.ensureComponent(Velocity.getComponentType());
      var3.ensureComponent(UUIDComponent.getComponentType());
      class="kw">return var3;
   }

   @Nonnull
   class="kw">public SimplePhysicsProvider initPhysics(@Nonnull BoundingBox var1) {
      this.simplePhysicsProvider.initialize(Projectile.getAssetMap().getAsset("Projectile"), var1);
      this.simplePhysicsProvider.setProvideCharacterCollisions(false);
      this.simplePhysicsProvider.setMoveOutOfSolid(true);
      class="kw">return this.simplePhysicsProvider;
   }

   @Nonnull
   class="kw">public BoundingBox updateHitbox(@Nonnull Ref<EntityStore> var1, @Nonnull CommandBuffer<EntityStore> var2) {
      BoundingBox var3 = this.createBoundingBoxComponent();
      var2.putComponent(var1, BoundingBox.getComponentType(), var3);
      class="kw">return var3;
   }

   @Nullable
   class="kw">public BoundingBox createBoundingBoxComponent() {
      if (this.blockTypeKey == null) {
         class="kw">return null;
      }

      BlockTypeAssetMap var1 = BlockType.getAssetMap();
      if (var1 == null) {
         class="kw">return null;
      }

      BlockType var2 = var1.getAsset(this.blockTypeKey);
      if (var2 == null) {
         class="kw">return null;
      }

      Vector3d var3 = new Vector3d(0.5);
      Box var4 = new Box(BlockBoundingBoxes.getAssetMap().getAsset(var2.getHitboxTypeIndex()).get(0).getBoundingBox());
      var4.min.sub(var3);
      var4.max.sub(var3);
      BoundingBox var5 = new BoundingBox(var4);
      var5.setBaseModelBox(var4);
      class="kw">return var5;
   }

   class="kw">public void setBlockTypeKey(String var1, @Nonnull Ref<EntityStore> var2, @Nonnull CommandBuffer<EntityStore> var3) {
      this.blockTypeKey = var1;
      this.isBlockIdNetworkOutdated = true;
      this.updateHitbox(var2, var3);
   }

   class="kw">public void setBlockTypeKey(String var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      this.blockTypeKey = var1;
      this.isBlockIdNetworkOutdated = true;
      BoundingBox var4 = this.createBoundingBoxComponent();
      if (var4 != null) {
         var3.putComponent(var2, BoundingBox.getComponentType(), var4);
      }
   }

   @Nonnull
   class="kw">public SimplePhysicsProvider getSimplePhysicsProvider() {
      class="kw">return this.simplePhysicsProvider;
   }

   class="kw">public String getBlockTypeKey() {
      class="kw">return this.blockTypeKey;
   }

   class="kw">public void addVelocity(float var1, float var2, float var3) {
      this.simplePhysicsProvider.addVelocity(var1, var2, var3);
   }

   class="kw">public void addVelocity(@Nonnull Vector3d var1) {
      this.simplePhysicsProvider.addVelocity((float)var1.x, (float)var1.y, (float)var1.z);
   }

   class="kw">public boolean consumeOutdatedAnchor() {
      if (this.shouldMoveOutdatedAnchor) {
         this.shouldMoveOutdatedAnchor = false;
         class="kw">return true;
      } else {
         class="kw">return false;
      }
   }

   class="kw">public boolean consumeBlockIdNetworkOutdated() {
      boolean var1 = this.isBlockIdNetworkOutdated;
      this.isBlockIdNetworkOutdated = false;
      class="kw">return var1;
   }

   @Nonnull
   @Override
   class="kw">public Component<EntityStore> clone() {
      BlockEntity var1 = new BlockEntity(this.blockTypeKey);
      var1.shouldMoveOutdatedAnchor = this.shouldMoveOutdatedAnchor;
      class="kw">return var1;
   }
}