Search in sources :

Example 6 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.

the class ProjectileEffectHelper method createChainReactionProjectile.

private static PersistentProjectileEntity createChainReactionProjectile(World world, LivingEntity attacker, ItemStack ammoStack, PersistentProjectileEntity originalArrow) {
    ArrowItem arrowItem = (ArrowItem) ((ArrowItem) (ammoStack.getItem() instanceof ArrowItem ? ammoStack.getItem() : Items.ARROW));
    PersistentProjectileEntity abstractArrowEntity = arrowItem.createArrow(world, ammoStack, attacker);
    if (attacker instanceof PlayerEntity) {
        abstractArrowEntity.setCritical(true);
    }
    abstractArrowEntity.setSound(SoundEvents.ITEM_CROSSBOW_HIT);
    abstractArrowEntity.setShotFromCrossbow(true);
    abstractArrowEntity.addScoreboardTag("ChainReactionProjectile");
    Set<String> originalArrowTags = originalArrow.getScoreboardTags();
    for (String tag : originalArrowTags) {
        abstractArrowEntity.addScoreboardTag(tag);
    }
    return abstractArrowEntity;
}
Also used : PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 7 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project Paradise-Lost by devs-immortal.

the class DartShooter method use.

@Override
public TypedActionResult<ItemStack> use(World worldIn, PlayerEntity playerIn, Hand handIn) {
    ItemStack heldItem = playerIn.getStackInHand(handIn);
    boolean bypassDartCheck = playerIn.isCreative() || EnchantmentHelper.getLevel(Enchantments.INFINITY, heldItem) > 0;
    ItemStack stack = this.findDartStack(playerIn);
    if (!stack.isEmpty() || bypassDartCheck) {
        if (stack.isEmpty())
            stack = new ItemStack(this.ammo);
        PersistentProjectileEntity projectile = this.ammo.createDart(worldIn, heldItem, playerIn);
        if (!worldIn.isClient) {
            projectile.setProperties(playerIn, playerIn.pitch, playerIn.yaw, 0.0F, 1.0F, 1.0F);
            worldIn.spawnEntity(projectile);
            if (!playerIn.isCreative()) {
                projectile.pickupType = PersistentProjectileEntity.PickupPermission.ALLOWED;
                stack.decrement(1);
            } else if (playerIn.isCreative())
                projectile.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
        }
    // worldIn.playSound(playerIn, playerIn.getBlockPos(), AetherSounds.DART_SHOOTER_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (playerIn.getRandom().nextFloat() * 0.4F + 0.8F));
    }
    return super.use(worldIn, playerIn, handIn);
}
Also used : PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) ItemStack(net.minecraft.item.ItemStack)

Example 8 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project Biome-Makeover by Lemonszz.

the class AdjudicatorMimicEntity method attack.

@Override
public void attack(LivingEntity target, float pullProgress) {
    ItemStack itemStack = this.getArrowType(this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.BOW)));
    PersistentProjectileEntity persistentProjectileEntity = this.createArrowProjectile(itemStack, pullProgress);
    double d = target.getX() - this.getX();
    double e = target.getBodyY(0.3333333333333333D) - persistentProjectileEntity.getY();
    double f = target.getZ() - this.getZ();
    double g = MathHelper.sqrt(d * d + f * f);
    persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - this.world.getDifficulty().getId() * 4));
    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntity(persistentProjectileEntity);
}
Also used : PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) ItemStack(net.minecraft.item.ItemStack)

Example 9 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project Capybara-Fabricated by ZestyBlaze.

the class CapybaraEntity method damage.

@Override
public boolean damage(DamageSource source, float amount) {
    if (this.isInvulnerableTo(source)) {
        return false;
    } else {
        Entity entity = source.getAttacker();
        this.setSitting(false);
        if (entity != null && !(entity instanceof PlayerEntity) && !(entity instanceof PersistentProjectileEntity)) {
            amount = (amount + 1.0f) / 2.0f;
        }
        return super.damage(source, amount);
    }
}
Also used : PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) MobEntity(net.minecraft.entity.mob.MobEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 10 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity 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)

Aggregations

PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)32 ItemStack (net.minecraft.item.ItemStack)19 LivingEntity (net.minecraft.entity.LivingEntity)13 PlayerEntity (net.minecraft.entity.player.PlayerEntity)12 Inject (org.spongepowered.asm.mixin.injection.Inject)10 Entity (net.minecraft.entity.Entity)8 Vec3d (net.minecraft.util.math.Vec3d)6 Quaternion (net.minecraft.util.math.Quaternion)5 EnchantmentHelper (net.minecraft.enchantment.EnchantmentHelper)4 ArrowItem (net.minecraft.item.ArrowItem)4 SoundEvents (net.minecraft.sound.SoundEvents)4 World (net.minecraft.world.World)4 List (java.util.List)3 Vector3f (net.minecraft.client.util.math.Vector3f)3 SnowballEntity (net.minecraft.entity.projectile.thrown.SnowballEntity)3 BowItem (net.minecraft.item.BowItem)3 MeleeRangedEnchantmentList (chronosacaria.mcdw.enchants.lists.MeleeRangedEnchantmentList)2 Comparator (java.util.Comparator)2 Random (java.util.Random)2 Set (java.util.Set)2