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
&& projectile.getShooter() instanceof Player
&& ((Player) projectile.getShooter()).getUniqueId().equals(
collidedWith.getUniqueId())) {
collidedWith.getUniqueId()))
|| collidedWith.getType() == EntityType.FIREBALL) {
event.setCancelled(true);
}

View File

@ -116,21 +116,22 @@ public final class WeaponMachineGun implements Listener {
final World world = player.getWorld();
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.setShooter(player);
arrow.setVelocity(velocity);
arrow.customName(Component.text("WeaponMachineGunBullet"));
arrow.setShooter(player);
arrow.setVelocity(velocity);
final float volume = 1.0F;
final float pitch = 63.0F;
world.playSound(
eyeLocation,
Sound.ENTITY_GENERIC_EXPLODE,
volume,
pitch
);
world.playSound(
eyeLocation,
Sound.ENTITY_GENERIC_EXPLODE,
volume,
pitch
);
});
numFiredBullets++;
machineGunActive.put(playerUUID, numFiredBullets);