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;
}
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);
}
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);
}
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);
}
}
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);
}
}
Aggregations