Search in sources :

Example 6 with ProjectileEntity

use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.

the class FuelTankBlock method onProjectileHit.

@Override
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
    if (!world.isClient) {
        Entity entity = projectile.getOwner();
        BlockPos blockPos = hit.getBlockPos();
        primeBlock(world, blockPos, entity instanceof LivingEntity ? (LivingEntity) entity : null);
        world.removeBlock(blockPos, false);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) FuelTankEntity(mod.azure.hwg.entity.projectiles.FuelTankEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 7 with ProjectileEntity

use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.

the class AbstractRangedAttack method shoot1.

public void shoot1() {
    LivingEntity livingentity = this.parentEntity.getTarget();
    World world = this.parentEntity.getEntityWorld();
    Vec3d vector3d = this.parentEntity.getRotationVec(1.0F);
    double d2 = livingentity.getX() - (this.parentEntity.getX() + vector3d.x * xOffSetModifier);
    double d3 = livingentity.getBodyY(0.5D) - (this.parentEntity.getBodyY(entityHeightFraction));
    double d4 = livingentity.getZ() - (this.parentEntity.getZ() + vector3d.z * zOffSetModifier);
    ProjectileEntity projectile = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
    projectile.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw(), 0.0F, 0.25F * 3.0F, 1.0F);
    projectile.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
    projectile.hasNoGravity();
    ProjectileEntity projectile1 = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
    projectile1.setVelocity(parentEntity, parentEntity.getPitch() + 2, parentEntity.getYaw(), 0.0F, 0.25F * 3.0F, 1.0F);
    projectile1.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
    projectile1.hasNoGravity();
    ProjectileEntity projectile2 = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
    projectile2.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw() + 2, 0.0F, 0.25F * 3.0F, 1.0F);
    projectile2.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
    projectile2.hasNoGravity();
    ProjectileEntity projectile3 = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
    projectile3.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw() - 2, 0.0F, 0.25F * 3.0F, 1.0F);
    projectile3.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
    projectile3.hasNoGravity();
    world.spawnEntity(projectile);
    world.spawnEntity(projectile1);
    world.spawnEntity(projectile2);
    world.spawnEntity(projectile3);
    if (sound == null)
        getDefaultAttackSound().play(this.parentEntity);
    else
        sound.play(this.parentEntity);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 8 with ProjectileEntity

use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.

the class AbstractRangedAttack method shoot.

public void shoot() {
    LivingEntity livingentity = this.parentEntity.getTarget();
    World world = this.parentEntity.getEntityWorld();
    Vec3d vector3d = this.parentEntity.getRotationVec(1.0F);
    double d2 = livingentity.getX() - (this.parentEntity.getX() + vector3d.x * xOffSetModifier);
    double d3 = livingentity.getBodyY(0.5D) - (this.parentEntity.getBodyY(entityHeightFraction));
    double d4 = livingentity.getZ() - (this.parentEntity.getZ() + vector3d.z * zOffSetModifier);
    ProjectileEntity projectile = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
    projectile.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw(), 0.0F, 0.25F * 3.0F, 1.0F);
    world.spawnEntity(projectile);
    if (sound == null)
        getDefaultAttackSound().play(this.parentEntity);
    else
        sound.play(this.parentEntity);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 9 with ProjectileEntity

use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.

the class FlareGunItem method shoot.

private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStack stack, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated) {
    if (!world.isClient) {
        BaseFlareEntity flareEntity = new BaseFlareEntity(world, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15000000596046448D, shooter.getZ(), true);
        boolean bl = projectile.getItem() == HWGItems.BLACK_FLARE;
        boolean b2 = projectile.getItem() == HWGItems.BLUE_FLARE;
        boolean b3 = projectile.getItem() == HWGItems.BROWN_FLARE;
        boolean b4 = projectile.getItem() == HWGItems.CYAN_FLARE;
        boolean b5 = projectile.getItem() == HWGItems.GRAY_FLARE;
        boolean b6 = projectile.getItem() == HWGItems.GREEN_FLARE;
        boolean b7 = projectile.getItem() == HWGItems.LIGHTBLUE_FLARE;
        boolean b8 = projectile.getItem() == HWGItems.LIGHTGRAY_FLARE;
        boolean b9 = projectile.getItem() == HWGItems.LIME_FLARE;
        boolean b10 = projectile.getItem() == HWGItems.MAGENTA_FLARE;
        boolean b11 = projectile.getItem() == HWGItems.ORANGE_FLARE;
        boolean b12 = projectile.getItem() == HWGItems.PINK_FLARE;
        boolean b13 = projectile.getItem() == HWGItems.PURPLE_FLARE;
        boolean b14 = projectile.getItem() == HWGItems.RED_FLARE;
        boolean b15 = projectile.getItem() == HWGItems.YELLOW_FLARE;
        if (bl) {
            flareEntity.setColor(1);
        } else if (b2) {
            flareEntity.setColor(2);
        } else if (b3) {
            flareEntity.setColor(3);
        } else if (b4) {
            flareEntity.setColor(4);
        } else if (b5) {
            flareEntity.setColor(5);
        } else if (b6) {
            flareEntity.setColor(6);
        } else if (b7) {
            flareEntity.setColor(7);
        } else if (b8) {
            flareEntity.setColor(8);
        } else if (b9) {
            flareEntity.setColor(9);
        } else if (b10) {
            flareEntity.setColor(10);
        } else if (b11) {
            flareEntity.setColor(11);
        } else if (b12) {
            flareEntity.setColor(12);
        } else if (b13) {
            flareEntity.setColor(13);
        } else if (b14) {
            flareEntity.setColor(14);
        } else if (b15) {
            flareEntity.setColor(15);
        } else {
            flareEntity.setColor(16);
        }
        Vec3d vec3d = shooter.getOppositeRotationVector(1.0F);
        Quaternion quaternion = new Quaternion(new Vec3f(vec3d), simulated, true);
        Vec3d vec3d2 = shooter.getRotationVec(1.0F);
        Vec3f vector3f = new Vec3f(vec3d2);
        vector3f.rotate(quaternion);
        ((ProjectileEntity) flareEntity).setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), speed, divergence);
        ((PersistentProjectileEntity) flareEntity).setDamage(0.3D);
        ((PersistentProjectileEntity) flareEntity).pickupType = PersistentProjectileEntity.PickupPermission.DISALLOWED;
        stack.damage(1, shooter, p -> p.sendToolBreakStatus(shooter.getActiveHand()));
        world.spawnEntity((Entity) flareEntity);
    }
}
Also used : ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Quaternion(net.minecraft.util.math.Quaternion) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Vec3f(net.minecraft.util.math.Vec3f) BaseFlareEntity(mod.azure.hwg.entity.projectiles.BaseFlareEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 10 with ProjectileEntity

use of net.minecraft.entity.projectile.ProjectileEntity in project Magma-1.16.x by magmafoundation.

the class CraftEventFactory method callBlockIgniteEvent.

public static BlockIgniteEvent callBlockIgniteEvent(World world, BlockPos pos, Entity igniter) {
    org.bukkit.World bukkitWorld = world.getWorldCB();
    org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
    IgniteCause cause;
    switch(bukkitIgniter.getType()) {
        case ENDER_CRYSTAL:
            cause = IgniteCause.ENDER_CRYSTAL;
            break;
        case LIGHTNING:
            cause = IgniteCause.LIGHTNING;
            break;
        case SMALL_FIREBALL:
        case FIREBALL:
            cause = IgniteCause.FIREBALL;
            break;
        case ARROW:
            cause = IgniteCause.ARROW;
            break;
        default:
            cause = IgniteCause.FLINT_AND_STEEL;
    }
    if (igniter instanceof ProjectileEntity) {
        Entity shooter = ((ProjectileEntity) igniter).getEntity();
        if (shooter != null) {
            bukkitIgniter = shooter.getBukkitEntity();
        }
    }
    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), cause, bukkitIgniter);
    world.getServerCB().getPluginManager().callEvent(event);
    return event;
}
Also used : ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) WaterMobEntity(net.minecraft.entity.passive.WaterMobEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) GolemEntity(net.minecraft.entity.passive.GolemEntity) AbstractRaiderEntity(net.minecraft.entity.monster.AbstractRaiderEntity) SlimeEntity(net.minecraft.entity.monster.SlimeEntity) LivingEntity(org.bukkit.entity.LivingEntity) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) StriderEntity(net.minecraft.entity.passive.StriderEntity) PotionEntity(net.minecraft.entity.projectile.PotionEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SpellcastingIllagerEntity(net.minecraft.entity.monster.SpellcastingIllagerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) MobEntity(net.minecraft.entity.MobEntity) HumanEntity(org.bukkit.entity.HumanEntity) Entity(net.minecraft.entity.Entity) GhastEntity(net.minecraft.entity.monster.GhastEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent) IgniteCause(org.bukkit.event.block.BlockIgniteEvent.IgniteCause)

Aggregations

ProjectileEntity (net.minecraft.entity.projectile.ProjectileEntity)22 LivingEntity (net.minecraft.entity.LivingEntity)12 PlayerEntity (net.minecraft.entity.player.PlayerEntity)11 Entity (net.minecraft.entity.Entity)10 Vec3d (net.minecraft.util.math.Vec3d)7 World (net.minecraft.world.World)7 BlockPos (net.minecraft.util.math.BlockPos)5 PotionEntity (net.minecraft.entity.projectile.PotionEntity)4 FireworkRocketEntity (net.minecraft.entity.projectile.FireworkRocketEntity)3 Random (java.util.Random)2 UUID (java.util.UUID)2 IPosition (net.minecraft.dispenser.IPosition)2 ProxyBlockSource (net.minecraft.dispenser.ProxyBlockSource)2 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)2 MobEntity (net.minecraft.entity.MobEntity)2 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)2 EnderPearlEntity (net.minecraft.entity.item.EnderPearlEntity)2 ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)2 ItemEntity (net.minecraft.entity.item.ItemEntity)2 VillagerEntity (net.minecraft.entity.merchant.villager.VillagerEntity)2