Search in sources :

Example 1 with MyPetEgg

use of de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetEgg in project MyPet by xXKeyleXx.

the class RangedAttack method shootProjectile.

public void shootProjectile(LivingEntity target, float damage, Projectile projectile) {
    Level world = target.level;
    double minY = this.target.getBoundingBox().minY;
    switch(projectile) {
        case Snowball:
            {
                MyPetSnowball snowball = new MyPetSnowball(world, entityMyPet);
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - snowball.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                snowball.setDamage(damage);
                snowball.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                world.addFreshEntity(snowball);
                break;
            }
        case Egg:
            {
                MyPetEgg egg = new MyPetEgg(world, entityMyPet);
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - egg.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                egg.setDamage(damage);
                egg.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                world.addFreshEntity(egg);
                break;
            }
        case LargeFireball:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetLargeFireball largeFireball = new MyPetLargeFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
                largeFireball.setPosRaw(largeFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), largeFireball.getZ());
                largeFireball.setDamage(damage);
                world.addFreshEntity(largeFireball);
                entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case SmallFireball:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetSmallFireball smallFireball = new MyPetSmallFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
                smallFireball.setPosRaw(smallFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), smallFireball.getZ());
                smallFireball.setDamage(damage);
                world.addFreshEntity(smallFireball);
                entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case WitherSkull:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetWitherSkull witherSkull = new MyPetWitherSkull(world, entityMyPet, distanceX, distanceY, distanceZ);
                witherSkull.setPosRaw(witherSkull.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), witherSkull.getZ());
                witherSkull.setDamage(damage);
                world.addFreshEntity(witherSkull);
                entityMyPet.makeSound("entity.wither.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case DragonFireball:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetDragonFireball dragonFireball = new MyPetDragonFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
                dragonFireball.setPosRaw(dragonFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), dragonFireball.getZ());
                dragonFireball.setDamage(damage);
                world.addFreshEntity(dragonFireball);
                entityMyPet.makeSound("entity.ender_dragon.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case Trident:
            {
                MyPetTrident trident = new MyPetTrident(world, entityMyPet);
                trident.setBaseDamage(damage);
                trident.setCritArrow(false);
                entityMyPet.makeSound("item.trident.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - trident.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                trident.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                world.addFreshEntity(trident);
                break;
            }
        case EnderPearl:
            {
                MyPetEnderPearl enderPearl = new MyPetEnderPearl(world, entityMyPet);
                enderPearl.setDamage(damage);
                entityMyPet.makeSound("entity.ender_pearl.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - enderPearl.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                enderPearl.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                world.addFreshEntity(enderPearl);
                break;
            }
        case LlamaSpit:
            {
                MyPetLlamaSpit llamaSpit = new MyPetLlamaSpit(world, entityMyPet);
                llamaSpit.setDamage(damage);
                entityMyPet.makeSound("entity.llama.spit", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + (target.getEyeHeight() / 3.0F) - llamaSpit.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2D;
                llamaSpit.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.5F, 10.0F);
                world.addFreshEntity(llamaSpit);
                break;
            }
        case Arrow:
        default:
            {
                Arrow arrow = new MyPetArrow(world, entityMyPet);
                arrow.setBaseDamage(damage);
                arrow.setCritArrow(false);
                entityMyPet.makeSound("entity.arrow.shoot", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - arrow.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                arrow.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                world.addFreshEntity(arrow);
                break;
            }
    }
}
Also used : MyPetArrow(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetArrow) Arrow(net.minecraft.world.entity.projectile.Arrow) MyPetDragonFireball(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetDragonFireball) MyPetEgg(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetEgg) MyPetEnderPearl(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetEnderPearl) MyPetArrow(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetArrow) MyPetLargeFireball(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetLargeFireball) MyPetSnowball(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetSnowball) MyPetTrident(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetTrident) Level(net.minecraft.world.level.Level) MyPetWitherSkull(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetWitherSkull) MyPetSmallFireball(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetSmallFireball) MyPetLlamaSpit(de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetLlamaSpit)

Example 2 with MyPetEgg

use of de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetEgg in project MyPet by xXKeyleXx.

the class RangedAttack method shootProjectile.

public void shootProjectile(LivingEntity target, float damage, Projectile projectile) {
    Level world = target.level;
    double minY = this.target.getBoundingBox().minY;
    switch(projectile) {
        case Snowball:
            {
                MyPetSnowball snowball = new MyPetSnowball(world, entityMyPet);
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - snowball.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                snowball.setDamage(damage);
                snowball.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                world.addFreshEntity(snowball);
                break;
            }
        case Egg:
            {
                MyPetEgg egg = new MyPetEgg(world, entityMyPet);
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - egg.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                egg.setDamage(damage);
                egg.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                world.addFreshEntity(egg);
                break;
            }
        case LargeFireball:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetLargeFireball largeFireball = new MyPetLargeFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
                largeFireball.setPosRaw(largeFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), largeFireball.getZ());
                largeFireball.setDamage(damage);
                world.addFreshEntity(largeFireball);
                entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case SmallFireball:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetSmallFireball smallFireball = new MyPetSmallFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
                smallFireball.setPosRaw(smallFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), smallFireball.getZ());
                smallFireball.setDamage(damage);
                world.addFreshEntity(smallFireball);
                entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case WitherSkull:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetWitherSkull witherSkull = new MyPetWitherSkull(world, entityMyPet, distanceX, distanceY, distanceZ);
                witherSkull.setPosRaw(witherSkull.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), witherSkull.getZ());
                witherSkull.setDamage(damage);
                world.addFreshEntity(witherSkull);
                entityMyPet.makeSound("entity.wither.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case DragonFireball:
            {
                double distanceX = this.target.getX() - entityMyPet.getX();
                double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F));
                double distanceZ = this.target.getZ() - entityMyPet.getZ();
                MyPetDragonFireball dragonFireball = new MyPetDragonFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
                dragonFireball.setPosRaw(dragonFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), dragonFireball.getZ());
                dragonFireball.setDamage(damage);
                world.addFreshEntity(dragonFireball);
                entityMyPet.makeSound("entity.ender_dragon.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
                break;
            }
        case Trident:
            {
                MyPetTrident trident = new MyPetTrident(world, entityMyPet);
                trident.setBaseDamage(damage);
                trident.setCritArrow(false);
                entityMyPet.makeSound("item.trident.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - trident.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                trident.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                world.addFreshEntity(trident);
                break;
            }
        case EnderPearl:
            {
                MyPetEnderPearl enderPearl = new MyPetEnderPearl(world, entityMyPet);
                enderPearl.setDamage(damage);
                entityMyPet.makeSound("entity.ender_pearl.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - enderPearl.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                enderPearl.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                world.addFreshEntity(enderPearl);
                break;
            }
        case LlamaSpit:
            {
                MyPetLlamaSpit llamaSpit = new MyPetLlamaSpit(world, entityMyPet);
                llamaSpit.setDamage(damage);
                entityMyPet.makeSound("entity.llama.spit", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + (target.getEyeHeight() / 3.0F) - llamaSpit.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2D;
                llamaSpit.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.5F, 10.0F);
                world.addFreshEntity(llamaSpit);
                break;
            }
        case Arrow:
        default:
            {
                Arrow arrow = new MyPetArrow(world, entityMyPet);
                arrow.setBaseDamage(damage);
                arrow.setCritArrow(false);
                entityMyPet.makeSound("entity.arrow.shoot", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
                double distanceX = target.getX() - entityMyPet.getX();
                double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - arrow.getY();
                double distanceZ = target.getZ() - entityMyPet.getZ();
                double distance20percent = Mth.sqrt((float) (distanceX * distanceX + distanceZ * distanceZ)) * 0.2F;
                arrow.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
                world.addFreshEntity(arrow);
                break;
            }
    }
}
Also used : MyPetArrow(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetArrow) Arrow(net.minecraft.world.entity.projectile.Arrow) MyPetDragonFireball(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetDragonFireball) MyPetEgg(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetEgg) MyPetEnderPearl(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetEnderPearl) MyPetArrow(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetArrow) MyPetLargeFireball(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetLargeFireball) MyPetSnowball(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetSnowball) MyPetTrident(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetTrident) Level(net.minecraft.world.level.Level) MyPetWitherSkull(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetWitherSkull) MyPetSmallFireball(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetSmallFireball) MyPetLlamaSpit(de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetLlamaSpit)

Aggregations

Arrow (net.minecraft.world.entity.projectile.Arrow)2 Level (net.minecraft.world.level.Level)2 MyPetArrow (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetArrow)1 MyPetDragonFireball (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetDragonFireball)1 MyPetEgg (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetEgg)1 MyPetEnderPearl (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetEnderPearl)1 MyPetLargeFireball (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetLargeFireball)1 MyPetLlamaSpit (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetLlamaSpit)1 MyPetSmallFireball (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetSmallFireball)1 MyPetSnowball (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetSnowball)1 MyPetTrident (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetTrident)1 MyPetWitherSkull (de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetWitherSkull)1 MyPetArrow (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetArrow)1 MyPetDragonFireball (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetDragonFireball)1 MyPetEgg (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetEgg)1 MyPetEnderPearl (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetEnderPearl)1 MyPetLargeFireball (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetLargeFireball)1 MyPetLlamaSpit (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetLlamaSpit)1 MyPetSmallFireball (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetSmallFireball)1 MyPetSnowball (de.Keyle.MyPet.compat.v1_18_R1.skill.skills.ranged.nms.MyPetSnowball)1