Search in sources :

Example 1 with SigilHolder

use of moriyashiine.bewitchment.common.block.entity.interfaces.SigilHolder in project bewitchment by MoriyaShiine.

the class SmellySigil method tick.

@Override
public int tick(World world, BlockPos pos) {
    int amount = 0;
    if (world.getTime() % 20 == 0) {
        SigilHolder sigil = ((SigilHolder) world.getBlockEntity(pos));
        double x = pos.getX() + 0.5, y = pos.getY() + 0.5, z = pos.getZ() + 0.5;
        for (HostileEntity entity : world.getEntitiesByClass(HostileEntity.class, new Box(pos).expand(16, 6, 16), LivingEntity::isAlive)) {
            if (!BWTags.TAGLOCK_BLACKLIST.contains(entity.getType()) && sigil.test(entity)) {
                if (entity.getNavigation().getTargetPos() == null || world.getBlockState(entity.getNavigation().getTargetPos()).getBlock() != BWObjects.SIGIL) {
                    if (entity.getTarget() == null && Math.sqrt(entity.squaredDistanceTo(new Vec3d(x, y, z))) > 3 && (entity.getNavigation().getTargetPos() == null || entity.getNavigation().getTargetPos().getSquaredDistance(pos) > 1)) {
                        entity.getNavigation().startMovingTo(x, y, z, 1);
                        amount++;
                    }
                }
            }
        }
    }
    return amount;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) HostileEntity(net.minecraft.entity.mob.HostileEntity) SigilHolder(moriyashiine.bewitchment.common.block.entity.interfaces.SigilHolder) Box(net.minecraft.util.math.Box) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

SigilHolder (moriyashiine.bewitchment.common.block.entity.interfaces.SigilHolder)1 LivingEntity (net.minecraft.entity.LivingEntity)1 HostileEntity (net.minecraft.entity.mob.HostileEntity)1 Box (net.minecraft.util.math.Box)1 Vec3d (net.minecraft.util.math.Vec3d)1