use of net.minecraft.entity.ICrossbowUser in project bioplethora by AquexTheSeal.
the class ArbitraryBallistaItem method shootProjectile.
private static void shootProjectile(World level, LivingEntity entity, Hand hand, ItemStack stack, ItemStack itemStack, float p_220016_5_, boolean b, float p_220016_7_, float p_220016_8_, float v) {
double x = entity.getX(), y = entity.getY(), z = entity.getZ();
BlockPos pos = entity.getEntity().blockPosition();
if (!level.isClientSide) {
boolean flag = itemStack.getItem() == Items.FIREWORK_ROCKET;
ProjectileEntity projectileentity;
if (flag) {
projectileentity = new FireworkRocketEntity(level, itemStack, entity, entity.getX(), entity.getEyeY() - (double) 0.15F, entity.getZ(), true);
} else {
projectileentity = getArrow(level, entity, stack, itemStack);
if (b || v != 0.0F) {
((AbstractArrowEntity) projectileentity).pickup = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY;
}
}
if ((!(level.isClientSide()))) {
((ServerWorld) level).sendParticles(ParticleTypes.CLOUD, x, y + 1.2, z, 25, 0.75, 0.75, 0.75, 0.01);
((ServerWorld) level).sendParticles(ParticleTypes.EXPLOSION, x, y + 1.2, z, 25, 0.75, 0.75, 0.75, 0);
}
level.playSound(null, x, y, z, SoundEvents.GENERIC_EXPLODE, SoundCategory.PLAYERS, 1, 1);
if (entity instanceof ICrossbowUser) {
ICrossbowUser icrossbowuser = (ICrossbowUser) entity;
icrossbowuser.shootCrossbowProjectile(icrossbowuser.getTarget(), stack, projectileentity, v);
} else {
Vector3d vector3d1 = entity.getUpVector(1.0F);
Quaternion quaternion = new Quaternion(new Vector3f(vector3d1), v, true);
Vector3d vector3d = entity.getViewVector(1.0F);
Vector3f vector3f = new Vector3f(vector3d);
vector3f.transform(quaternion);
projectileentity.shoot(vector3f.x(), vector3f.y(), vector3f.z(), p_220016_7_, p_220016_8_);
}
stack.hurtAndBreak(flag ? 3 : 1, entity, (living) -> living.broadcastBreakEvent(hand));
level.addFreshEntity(projectileentity);
level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, p_220016_5_);
}
}
Aggregations