Machine Gun: Avoid exception in Folia

Not a great solution, but it will do for now.
This commit is contained in:
kaboom 2023-03-31 22:08:11 +03:00
parent 7177cd1767
commit 42df4d8795
2 changed files with 15 additions and 14 deletions

View file

@ -88,7 +88,7 @@ public final class WeaponArmageddon implements Listener {
if ((collidedWith.getType() == EntityType.PLAYER if ((collidedWith.getType() == EntityType.PLAYER
&& projectile.getShooter() instanceof Player && projectile.getShooter() instanceof Player
&& ((Player) projectile.getShooter()).getUniqueId().equals( && ((Player) projectile.getShooter()).getUniqueId().equals(
collidedWith.getUniqueId())) { collidedWith.getUniqueId()))
|| collidedWith.getType() == EntityType.FIREBALL) { || collidedWith.getType() == EntityType.FIREBALL) {
event.setCancelled(true); event.setCancelled(true);
} }

View file

@ -116,21 +116,22 @@ public final class WeaponMachineGun implements Listener {
final World world = player.getWorld(); final World world = player.getWorld();
final Vector velocity = eyeLocation.getDirection().multiply(12); final Vector velocity = eyeLocation.getDirection().multiply(12);
final Arrow arrow = player.launchProjectile(Arrow.class); world.getChunkAtAsync(eyeLocation).thenAccept(chunk -> {
final Arrow arrow = player.launchProjectile(Arrow.class);
final float volume = 1.0F;
final float pitch = 63.0F;
arrow.customName(Component.text("WeaponMachineGunBullet")); arrow.customName(Component.text("WeaponMachineGunBullet"));
arrow.setShooter(player); arrow.setShooter(player);
arrow.setVelocity(velocity); arrow.setVelocity(velocity);
final float volume = 1.0F; world.playSound(
final float pitch = 63.0F; eyeLocation,
Sound.ENTITY_GENERIC_EXPLODE,
world.playSound( volume,
eyeLocation, pitch
Sound.ENTITY_GENERIC_EXPLODE, );
volume, });
pitch
);
numFiredBullets++; numFiredBullets++;
machineGunActive.put(playerUUID, numFiredBullets); machineGunActive.put(playerUUID, numFiredBullets);