Search in sources :

Example 6 with Box

use of net.minecraft.util.math.Box in project MCDoom by AzureDoom.

the class ArgentBoltEntity method explode.

protected void explode() {
    double xn = MathHelper.floor(this.getX() - 5.0D);
    double xp = MathHelper.floor(this.getX() + 7.0D);
    double yn = MathHelper.floor(this.getY() - 5.0D);
    double yp = MathHelper.floor(this.getY() + 7.0D);
    double zn = MathHelper.floor(this.getZ() - 5.0D);
    double zp = MathHelper.floor(this.getZ() + 7.0D);
    List<Entity> list = this.world.getOtherEntities(this, new Box(xn, yn, zn, xp, yp, zp));
    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)) / 6);
        if (entity instanceof LivingEntity) {
            if (y <= 1.0D) {
                entity.damage(DamageSource.player((PlayerEntity) this.shooter), config.argent_bolt_damage);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) TickingLightEntity(mod.azure.doom.entity.tileentity.TickingLightEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Box(net.minecraft.util.math.Box) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 7 with Box

use of net.minecraft.util.math.Box 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 8 with Box

use of net.minecraft.util.math.Box 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 9 with Box

use of net.minecraft.util.math.Box in project MCDoom by AzureDoom.

the class DoomFireEntity method tick.

public void tick() {
    super.tick();
    if (--this.warmup < 0) {
        if (!this.startedAttack) {
            this.world.sendEntityStatus(this, (byte) 4);
            this.startedAttack = true;
        }
        if (--this.ticksLeft < 0) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    if (this.isAlive() && world.getBlockState(this.getBlockPos().up()).isAir()) {
        world.setBlockState(this.getBlockPos().up(), AbstractFireBlock.getState(world, this.getBlockPos().up()));
    }
    List<Entity> list = this.world.getOtherEntities(this, new Box(this.getBlockPos().up()).expand(1D, 1D, 1D));
    for (int x = 0; x < list.size(); ++x) {
        Entity entity = (Entity) list.get(x);
        if (!(entity instanceof MancubusEntity) && !(entity instanceof ArchvileEntity) && !(entity instanceof IconofsinEntity) && !(entity instanceof DoomHunterEntity) && !(entity instanceof SummonerEntity) && !(entity instanceof MotherDemonEntity)) {
            double y = (double) (MathHelper.sqrt(entity.distanceTo(this)));
            if (y <= 1.0D) {
                if (entity.isAlive()) {
                    entity.damage(DamageSource.mobProjectile(entity, this.getOwner()), damage);
                    entity.setFireTicks(60);
                }
            }
        }
    }
}
Also used : SummonerEntity(mod.azure.doom.entity.tiersuperheavy.SummonerEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) ArchvileEntity(mod.azure.doom.entity.tiersuperheavy.ArchvileEntity) DoomHunterEntity(mod.azure.doom.entity.tiersuperheavy.DoomHunterEntity) Entity(net.minecraft.entity.Entity) MotherDemonEntity(mod.azure.doom.entity.tierboss.MotherDemonEntity) LivingEntity(net.minecraft.entity.LivingEntity) MancubusEntity(mod.azure.doom.entity.tierheavy.MancubusEntity) ArchvileEntity(mod.azure.doom.entity.tiersuperheavy.ArchvileEntity) MotherDemonEntity(mod.azure.doom.entity.tierboss.MotherDemonEntity) Box(net.minecraft.util.math.Box) MancubusEntity(mod.azure.doom.entity.tierheavy.MancubusEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) SummonerEntity(mod.azure.doom.entity.tiersuperheavy.SummonerEntity) DoomHunterEntity(mod.azure.doom.entity.tiersuperheavy.DoomHunterEntity)

Example 10 with Box

use of net.minecraft.util.math.Box in project MCDoom by AzureDoom.

the class SwordCrucibleItem method onStoppedUsing.

@Override
public void onStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int remainingUseTicks) {
    if (entityLiving instanceof PlayerEntity) {
        PlayerEntity playerentity = (PlayerEntity) entityLiving;
        if (stack.getDamage() < (stack.getMaxDamage() - 1)) {
            playerentity.getItemCooldownManager().set(this, 200);
            final Box aabb = new Box(entityLiving.getBlockPos().up()).expand(4D, 1D, 4D);
            entityLiving.getEntityWorld().getOtherEntities(entityLiving, aabb).forEach(e -> doDamage(entityLiving, e));
            stack.damage(1, entityLiving, p -> p.sendToolBreakStatus(entityLiving.getActiveHand()));
            if (!worldIn.isClient) {
                final int id = GeckoLibUtil.guaranteeIDForStack(stack, (ServerWorld) worldIn);
                GeckoLibNetwork.syncAnimation(playerentity, this, id, ANIM_OPEN);
                for (PlayerEntity otherPlayer : PlayerLookup.tracking(playerentity)) {
                    GeckoLibNetwork.syncAnimation(otherPlayer, this, id, ANIM_OPEN);
                }
            }
        }
    }
}
Also used : Box(net.minecraft.util.math.Box) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

Box (net.minecraft.util.math.Box)146 Vec3d (net.minecraft.util.math.Vec3d)54 LivingEntity (net.minecraft.entity.LivingEntity)47 PlayerEntity (net.minecraft.entity.player.PlayerEntity)42 BlockPos (net.minecraft.util.math.BlockPos)41 Entity (net.minecraft.entity.Entity)40 Direction (net.minecraft.util.math.Direction)18 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)17 List (java.util.List)15 VoxelShape (net.minecraft.util.shape.VoxelShape)14 BlockState (net.minecraft.block.BlockState)12 ArrayList (java.util.ArrayList)11 Comparator (java.util.Comparator)11 ItemStack (net.minecraft.item.ItemStack)11 World (net.minecraft.world.World)11 Random (java.util.Random)10 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)10 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)10 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)10 DemonEntity (mod.azure.doom.entity.DemonEntity)9