Search in sources :

Example 1 with HostileEntity

use of net.minecraft.entity.mob.HostileEntity in project MCDoom by AzureDoom.

the class BFGEntity method doDamage.

public void doDamage() {
    float q = 24.0F;
    int k = MathHelper.floor(this.getX() - (double) q - 1.0D);
    int l = MathHelper.floor(this.getX() + (double) q + 1.0D);
    int t = MathHelper.floor(this.getY() - (double) q - 1.0D);
    int u = MathHelper.floor(this.getY() + (double) q + 1.0D);
    int v = MathHelper.floor(this.getZ() - (double) q - 1.0D);
    int w = MathHelper.floor(this.getZ() + (double) q + 1.0D);
    List<Entity> list = this.world.getOtherEntities(this, new Box((double) k, (double) t, (double) v, (double) l, (double) u, (double) w));
    Vec3d vec3d = new Vec3d(this.getX(), this.getY(), this.getZ());
    for (int x = 0; x < list.size(); ++x) {
        Entity entity = (Entity) list.get(x);
        double y = (double) (MathHelper.sqrt((float) entity.squaredDistanceTo(vec3d)) / q);
        if (!(entity instanceof PlayerEntity || entity instanceof EnderDragonEntity || entity instanceof GoreNestEntity || entity instanceof IconofsinEntity) && (entity instanceof HostileEntity || entity instanceof SlimeEntity || entity instanceof PhantomEntity || entity instanceof ShulkerEntity || entity instanceof HoglinEntity)) {
            if (y <= 1.0D) {
                entity.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage);
                if (!this.world.isClient) {
                    List<LivingEntity> list1 = this.world.getNonSpectatingEntities(LivingEntity.class, this.getBoundingBox().expand(4.0D, 2.0D, 4.0D));
                    AreaEffectCloudEntity areaeffectcloudentity = new AreaEffectCloudEntity(entity.world, entity.getX(), entity.getY(), entity.getZ());
                    areaeffectcloudentity.setParticleType(ParticleTypes.TOTEM_OF_UNDYING);
                    areaeffectcloudentity.setRadius(3.0F);
                    areaeffectcloudentity.setDuration(10);
                    if (!list1.isEmpty()) {
                        for (LivingEntity livingentity : list1) {
                            double d0 = this.squaredDistanceTo(livingentity);
                            if (d0 < 16.0D) {
                                areaeffectcloudentity.updatePosition(entity.getX(), entity.getEyeY(), entity.getZ());
                                break;
                            }
                        }
                    }
                    this.world.spawnEntity(areaeffectcloudentity);
                }
            }
        }
        if (entity instanceof EnderDragonEntity) {
            if (entity.isAlive()) {
                ((EnderDragonEntity) entity).head.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage_dragon);
            }
        }
        if (entity instanceof IconofsinEntity) {
            if (entity.isAlive()) {
                entity.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage * 0.1F);
            }
        }
    }
}
Also used : SlimeEntity(net.minecraft.entity.mob.SlimeEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) TickingLightEntity(mod.azure.doom.entity.tileentity.TickingLightEntity) HoglinEntity(net.minecraft.entity.mob.HoglinEntity) PhantomEntity(net.minecraft.entity.mob.PhantomEntity) ShulkerEntity(net.minecraft.entity.mob.ShulkerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) HostileEntity(net.minecraft.entity.mob.HostileEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) SlimeEntity(net.minecraft.entity.mob.SlimeEntity) Entity(net.minecraft.entity.Entity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) GoreNestEntity(mod.azure.doom.entity.tierambient.GoreNestEntity) HoglinEntity(net.minecraft.entity.mob.HoglinEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) Box(net.minecraft.util.math.Box) ShulkerEntity(net.minecraft.entity.mob.ShulkerEntity) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) HostileEntity(net.minecraft.entity.mob.HostileEntity) PhantomEntity(net.minecraft.entity.mob.PhantomEntity) GoreNestEntity(mod.azure.doom.entity.tierambient.GoreNestEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity)

Example 2 with HostileEntity

use of net.minecraft.entity.mob.HostileEntity in project MCDoom by AzureDoom.

the class BFGEntity method tick.

@Override
public void tick() {
    int idleOpt = 100;
    if (getVelocity().lengthSquared() < 0.01)
        idleTicks++;
    else
        idleTicks = 0;
    if (idleOpt <= 0 || idleTicks < idleOpt)
        super.tick();
    boolean isInsideWaterBlock = world.isWater(getBlockPos());
    spawnLightSource(isInsideWaterBlock);
    if (this.age >= 100) {
        this.remove(Entity.RemovalReason.DISCARDED);
    }
    float q = 24.0F;
    int k = MathHelper.floor(this.getX() - (double) q - 1.0D);
    int l = MathHelper.floor(this.getX() + (double) q + 1.0D);
    int t = MathHelper.floor(this.getY() - (double) q - 1.0D);
    int u = MathHelper.floor(this.getY() + (double) q + 1.0D);
    int v = MathHelper.floor(this.getZ() - (double) q - 1.0D);
    int w = MathHelper.floor(this.getZ() + (double) q + 1.0D);
    List<Entity> list = this.world.getOtherEntities(this, new Box((double) k, (double) t, (double) v, (double) l, (double) u, (double) w));
    Vec3d vec3d1 = new Vec3d(this.getX(), this.getY(), this.getZ());
    for (int x = 0; x < list.size(); ++x) {
        Entity entity = (Entity) list.get(x);
        double y = (double) (MathHelper.sqrt((float) entity.squaredDistanceTo(vec3d1)) / q);
        if (!(entity instanceof PlayerEntity || entity instanceof EnderDragonEntity || entity instanceof GoreNestEntity || entity instanceof IconofsinEntity) && (entity instanceof HostileEntity || entity instanceof SlimeEntity || entity instanceof PhantomEntity || entity instanceof ShulkerEntity || entity instanceof HoglinEntity)) {
            if (y <= 1.0D) {
                if (entity.isAlive()) {
                    entity.damage(DamageSource.explosion(this.shooter), DoomMod.config.weapons.bfgball_damage_aoe);
                    setBeamTarget(entity.getId());
                }
            }
        }
        if (entity instanceof IconofsinEntity) {
            if (entity.isAlive()) {
                entity.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage_aoe * 0.1F);
            }
        }
        if (!(entity instanceof PlayerEntity) && entity instanceof EnderDragonEntity) {
            if (entity.isAlive()) {
                ((EnderDragonEntity) entity).head.damage(DamageSource.player((PlayerEntity) this.shooter), DoomMod.config.weapons.bfgball_damage_aoe);
                setBeamTarget(entity.getId());
            }
        }
    }
}
Also used : SlimeEntity(net.minecraft.entity.mob.SlimeEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) TickingLightEntity(mod.azure.doom.entity.tileentity.TickingLightEntity) HoglinEntity(net.minecraft.entity.mob.HoglinEntity) PhantomEntity(net.minecraft.entity.mob.PhantomEntity) ShulkerEntity(net.minecraft.entity.mob.ShulkerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) HostileEntity(net.minecraft.entity.mob.HostileEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) SlimeEntity(net.minecraft.entity.mob.SlimeEntity) Entity(net.minecraft.entity.Entity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) GoreNestEntity(mod.azure.doom.entity.tierambient.GoreNestEntity) HoglinEntity(net.minecraft.entity.mob.HoglinEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) Box(net.minecraft.util.math.Box) ShulkerEntity(net.minecraft.entity.mob.ShulkerEntity) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) HostileEntity(net.minecraft.entity.mob.HostileEntity) PhantomEntity(net.minecraft.entity.mob.PhantomEntity) GoreNestEntity(mod.azure.doom.entity.tierambient.GoreNestEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity)

Example 3 with HostileEntity

use of net.minecraft.entity.mob.HostileEntity in project bewitchment by MoriyaShiine.

the class PushMobsRitualFunction method tick.

@Override
public void tick(World world, BlockPos glyphPos, BlockPos effectivePos, boolean catFamiliar) {
    if (!world.isClient) {
        int radius = catFamiliar ? 24 : 8;
        if (world.getTime() % 5 == 0) {
            for (HostileEntity hostileEntity : world.getEntitiesByClass(HostileEntity.class, new Box(effectivePos).expand(radius, 0, radius), LivingEntity::isAlive)) {
                double distanceX = effectivePos.getX() - hostileEntity.getX();
                double distanceZ = effectivePos.getZ() - hostileEntity.getZ();
                double max = MathHelper.absMax(distanceX, distanceZ);
                if (max >= 0) {
                    max = MathHelper.sqrt((float) max);
                    distanceX /= max;
                    distanceZ /= max;
                    distanceX *= Math.min(1, 1 / max);
                    distanceZ *= Math.min(1, 1 / max);
                    distanceX /= 2;
                    distanceZ /= 2;
                    hostileEntity.addVelocity(-distanceX, 0, -distanceZ);
                }
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) HostileEntity(net.minecraft.entity.mob.HostileEntity) Box(net.minecraft.util.math.Box)

Example 4 with HostileEntity

use of net.minecraft.entity.mob.HostileEntity 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

LivingEntity (net.minecraft.entity.LivingEntity)4 HostileEntity (net.minecraft.entity.mob.HostileEntity)4 Box (net.minecraft.util.math.Box)4 Vec3d (net.minecraft.util.math.Vec3d)3 GoreNestEntity (mod.azure.doom.entity.tierambient.GoreNestEntity)2 IconofsinEntity (mod.azure.doom.entity.tierboss.IconofsinEntity)2 TickingLightEntity (mod.azure.doom.entity.tileentity.TickingLightEntity)2 BlockEntity (net.minecraft.block.entity.BlockEntity)2 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)2 Entity (net.minecraft.entity.Entity)2 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)2 HoglinEntity (net.minecraft.entity.mob.HoglinEntity)2 PhantomEntity (net.minecraft.entity.mob.PhantomEntity)2 ShulkerEntity (net.minecraft.entity.mob.ShulkerEntity)2 SlimeEntity (net.minecraft.entity.mob.SlimeEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)2 SigilHolder (moriyashiine.bewitchment.common.block.entity.interfaces.SigilHolder)1