content: package com.github.alexthe666.iceandfire.entity;
  
  import com.github.alexthe666.iceandfire.IceAndFire;
  import com.github.alexthe666.iceandfire.entity.util.IBlacklistedFromStatues;
  import com.google.common.collect.ImmutableList;
  import net.minecraft.nbt.CompoundTag;
  import net.minecraft.network.syncher.EntityDataAccessor;
  import net.minecraft.network.syncher.EntityDataSerializers;
  import net.minecraft.network.syncher.SynchedEntityData;
  import net.minecraft.world.damagesource.DamageSource;
  import net.minecraft.world.entity.*;
  import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
  import net.minecraft.world.entity.ai.attributes.Attributes;
  import net.minecraft.world.entity.player.Player;
  import net.minecraft.world.item.ItemStack;
  import net.minecraft.world.level.Level;
  import net.minecraftforge.registries.ForgeRegistries;
  import org.jetbrains.annotations.NotNull;
  
  public class EntityStoneStatue extends LivingEntity implements IBlacklistedFromStatues {
  
      private static final EntityDataAccessor<String> TRAPPED_ENTITY_TYPE = SynchedEntityData.defineId(EntityStoneStatue.class, EntityDataSerializers.STRING);
      private static final EntityDataAccessor<CompoundTag> TRAPPED_ENTITY_DATA = SynchedEntityData.defineId(EntityStoneStatue.class, EntityDataSerializers.COMPOUND_TAG);
      private static final EntityDataAccessor<Float> TRAPPED_ENTITY_WIDTH = SynchedEntityData.defineId(EntityStoneStatue.class, EntityDataSerializers.FLOAT);
      private static final EntityDataAccessor<Float> TRAPPED_ENTITY_HEIGHT = SynchedEntityData.defineId(EntityStoneStatue.class, EntityDataSerializers.FLOAT);
      private static final EntityDataAccessor<Float> TRAPPED_ENTITY_SCALE = SynchedEntityData.defineId(EntityStoneStatue.class, EntityDataSerializers.FLOAT);
      private static final EntityDataAccessor<Integer> CRACK_AMOUNT = SynchedEntityData.defineId(EntityStoneStatue.class, EntityDataSerializers.INT);
      private EntityDimensions stoneStatueSize = EntityDimensions.fixed(0.5F, 0.5F);
  
      public EntityStoneStatue(EntityType<? extends LivingEntity> t, Level worldIn) {
          super(t, worldIn);
      }
  
      public static AttributeSupplier.Builder bakeAttributes() {
          return Mob.createMobAttributes()
              //HEALTH
              .add(Attributes.MAX_HEALTH, 20)
              //SPEED
              .add(Attributes.MOVEMENT_SPEED, 0.0D)
              //ATTACK
              .add(Attributes.ATTACK_DAMAGE, 1.0D);
      }
  
      public static EntityStoneStatue buildStatueEntity(LivingEntity parent) {
          EntityStoneStatue statue = IafEntityRegistry.STONE_STATUE.get().create(parent.level);
          CompoundTag entityTag = new CompoundTag();
          try {
              if (!(parent instanceof Player)) {
                  parent.saveWithoutId(entityTag);
              }
          } catch (Exception e) {
              IceAndFire.LOGGER.debug("Encountered issue creating stone statue from {}", parent);
          }
          statue.setTrappedTag(entityTag);
          statue.setTrappedEntityTypeString(ForgeRegistries.ENTITIES.getKey(parent.getType()).toString());
          statue.setTrappedEntityWidth(parent.getBbWidth());
          statue.setTrappedHeight(parent.getBbHeight());
          statue.setTrappedScale(parent.getScale());
  
          return statue;
      }
  
      @Override
      public void push(@NotNull Entity entityIn) {
      }
  
      @Override
      public void baseTick() {
  
      }
  
      @Override
      protected void defineSynchedData() {
          super.defineSynchedData();
          this.entityData.define(TRAPPED_ENTITY_TYPE, "minecraft:pig");
          this.entityData.define(TRAPPED_ENTITY_DATA, new CompoundTag());
          this.entityData.define(TRAPPED_ENTITY_WIDTH, 0.5F);
          this.entityData.define(TRAPPED_ENTITY_HEIGHT, 0.5F);
          this.entityData.define(TRAPPED_ENTITY_SCALE, 1F);
          this.entityData.define(CRACK_AMOUNT, 0);
      }
  
      public EntityType getTrappedEntityType() {
          String str = getTrappedEntityTypeString();
          return EntityType.byString(str).orElse(EntityType.PIG);
      }
  
      public String getTrappedEntityTypeString() {
          return this.entityData.get(TRAPPED_ENTITY_TYPE);
      }
  
      public void setTrappedEntityTypeString(String string) {
          this.entityData.set(TRAPPED_ENTITY_TYPE, string);
      }
  
      public CompoundTag getTrappedTag() {
          return this.entityData.get(TRAPPED_ENTITY_DATA);
      }
  
      public void setTrappedTag(CompoundTag tag) {
          this.entityData.set(TRAPPED_ENTITY_DATA, tag);
      }
  
      public float getTrappedWidth() {
          return this.entityData.get(TRAPPED_ENTITY_WIDTH);
      }
  
      public void setTrappedEntityWidth(float size) {
          this.entityData.set(TRAPPED_ENTITY_WIDTH, size);
      }
  
      public float getTrappedHeight() {
          return this.entityData.get(TRAPPED_ENTITY_HEIGHT);
      }
  
      public void setTrappedHeight(float size) {
          this.entityData.set(TRAPPED_ENTITY_HEIGHT, size);
      }
  
      public float getTrappedScale() {
          return this.entityData.get(TRAPPED_ENTITY_SCALE);
      }
  
      public void setTrappedScale(float size) {
          this.entityData.set(TRAPPED_ENTITY_SCALE, size);
      }
  
      @Override
      public void addAdditionalSaveData(@NotNull CompoundTag tag) {
          super.addAdditionalSaveData(tag);
          tag.putInt("CrackAmount", this.getCrackAmount());
          tag.putFloat("StatueWidth", this.getTrappedWidth());
          tag.putFloat("StatueHeight", this.getTrappedHeight());
          tag.putFloat("StatueScale", this.getTrappedScale());
          tag.putString("StatueEntityType", this.getTrappedEntityTypeString());
          tag.put("StatueEntityTag", this.getTrappedTag());
      }
  
      @Override
      public float getScale() {
          return this.getTrappedScale();
      }
  
      @Override
      public void readAdditionalSaveData(@NotNull CompoundTag tag) {
          super.readAdditionalSaveData(tag);
          this.setCrackAmount(tag.getByte("CrackAmount"));
          this.setTrappedEntityWidth(tag.getFloat("StatueWidth"));
          this.setTrappedHeight(tag.getFloat("StatueHeight"));
          this.setTrappedScale(tag.getFloat("StatueScale"));
          this.setTrappedEntityTypeString(tag.getString("StatueEntityType"));
          if (tag.contains("StatueEntityTag")) {
              this.setTrappedTag(tag.getCompound("StatueEntityTag"));
  
          }
      }
  
      @Override
      public boolean hurt(@NotNull DamageSource source, float amount) {
          return source == DamageSource.OUT_OF_WORLD;
      }
  
      @Override
      public @NotNull EntityDimensions getDimensions(@NotNull Pose poseIn) {
          return stoneStatueSize;
      }
  
      @Override
      public void tick() {
          super.tick();
          this.setYRot(this.yBodyRot);
          this.yHeadRot = this.getYRot();
          if (Math.abs(this.getBbWidth() - getTrappedWidth()) > 0.01 || Math.abs(this.getBbHeight() - getTrappedHeight()) > 0.01) {
              double prevX = this.getX();
              double prevZ = this.getZ();
              this.stoneStatueSize = EntityDimensions.scalable(getTrappedWidth(), getTrappedHeight());
              refreshDimensions();
              this.setPos(prevX, this.getY(), prevZ);
          }
      }
  
      @Override
      public void kill() {
          this.remove(RemovalReason.KILLED);
      }
  
      @Override
      public @NotNull Iterable<ItemStack> getArmorSlots() {
          return ImmutableList.of();
      }
  
      @Override
      public @NotNull ItemStack getItemBySlot(@NotNull EquipmentSlot slotIn) {
          return ItemStack.EMPTY;
      }
  
      @Override
      public void setItemSlot(@NotNull EquipmentSlot slotIn, @NotNull ItemStack stack) {
  
      }
  
      @Override
      public @NotNull HumanoidArm getMainArm() {
          return HumanoidArm.RIGHT;
      }
  
      public int getCrackAmount() {
          return this.entityData.get(CRACK_AMOUNT);
      }
  
      public void setCrackAmount(int crackAmount) {
          this.entityData.set(CRACK_AMOUNT, crackAmount);
      }
  
  
      @Override
      public boolean canBreatheUnderwater() {
          return true;
      }
  
      @Override
      public boolean canBeTurnedToStone() {
          return false;
      }
  }
  