Forge Mod

TerrorStalkerMod

entity stock everywhere you go scare you every once a while make noise and footsteps and very very terrifying

src/main/java/eu/codexe/terrorstalkermod/entity/TerrorStalkerEntity.java
package eu.codexe.terrorstalkermod.entity;

import net.minecraft.core.BlockPos;
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.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
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.level.Level;

public class TerrorStalkerEntity extends Mob {
    private static final EntityDataAccessor<Integer> PHASE = SynchedEntityData.defineId(TerrorStalkerEntity.class, EntityDataSerializers.INT);
    private static final int DESPAWN_TICKS = 600;

    public TerrorStalkerEntity(EntityType<? extends TerrorStalkerEntity> entityType, Level level) {
        super(entityType, level);
        this.noPhysics = true;
        this.setNoAi(true);
        this.xpReward = 0;
    }

    public static AttributeSupplier.Builder createAttributes() {
        return Mob.createMobAttributes()
                .add(Attributes.MAX_HEALTH, 40.0D)
                .add(Attributes.MOVEMENT_SPEED, 0.35D)
                .add(Attributes.FOLLOW_RANGE, 64.0D)
                .add(Attributes.ATTACK_DAMAGE, 8.0D);
    }

    @Override
    protected void defineSynchedData() {
        this.entityData.define(PHASE, 0);
    }

    @Override
    public void tick() {
        super.tick();

        if (this.level().isClientSide) {
            this.updateClientPhase();
            return;
        }

        Player target = this.level().getNearestPlayer(this, 24.0D);
        if (target != null) {
            this.lookAt(target, 90.0F, 90.0F);
            if (this.distanceToSqr(target) < 6.0D) {
                target.playSound(SoundEvents.ENTITY_ENDERMAN_AMBIENT, 0.9F, 0.65F + this.random.nextFloat() * 0.2F);
            }
        }