diff --git a/patches/server/0010-Add-SoundEvent.patch b/patches/server/0010-Add-SoundEvent.patch index 47c120e..c810b9b 100644 --- a/patches/server/0010-Add-SoundEvent.patch +++ b/patches/server/0010-Add-SoundEvent.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: lexikiq -Date: Sat, 5 Jun 2021 01:04:44 -0400 +Date: Sat, 5 Jun 2021 01:20:22 -0400 Subject: [PATCH] Add SoundEvent @@ -471,7 +471,7 @@ index 05248f560d643080a3eac581c01aa89fb3709e6c..7ccf0619cafe3c1bf83333ac2235d1fd @Override diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index f0bd5b57ffd7e55299180b382551afe06bd764f8..e914674250bc8032bff56721992b9bdba4f2da79 100644 +index f0bd5b57ffd7e55299180b382551afe06bd764f8..6565ca7b3bd42faf985998d76f4c55b8c4620b6d 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -228,6 +228,19 @@ import org.bukkit.inventory.meta.BookMeta; @@ -494,27 +494,14 @@ index f0bd5b57ffd7e55299180b382551afe06bd764f8..e914674250bc8032bff56721992b9bdb public class CraftEventFactory { public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.BURN); -@@ -1832,4 +1845,44 @@ public class CraftEventFactory { +@@ -1832,4 +1845,32 @@ public class CraftEventFactory { return event.callEvent(); } // Paper end + + // Parchment start + public static @org.jetbrains.annotations.Nullable Packet handleSoundEvent(SoundEvent _event) { -+ org.bukkit.World world; -+ if (_event instanceof LocationNamedSoundEvent) -+ world = ((LocationNamedSoundEvent) _event).getWorld(); -+ else if (_event instanceof LocationCustomSoundEvent) -+ world = ((LocationCustomSoundEvent) _event).getWorld(); -+ else if (_event instanceof EntitySoundEvent) -+ world = ((EntitySoundEvent) _event).getOrigin().getWorld(); -+ else -+ throw new IllegalArgumentException("Could not find world"); -+ -+ if (!(world instanceof CraftWorld)) // mostly just ensuring the world isn't null -+ throw new IllegalArgumentException("World was not a CraftWorld as expected"); -+ -+ java.util.concurrent.CompletableFuture failure = java.util.concurrent.CompletableFuture.supplyAsync(_event::callEvent, ((CraftWorld) world).getHandle().getMinecraftServer()); ++ java.util.concurrent.CompletableFuture failure = java.util.concurrent.CompletableFuture.supplyAsync(_event::callEvent); + try { + if (failure.get()) + return null; @@ -532,10 +519,11 @@ index f0bd5b57ffd7e55299180b382551afe06bd764f8..e914674250bc8032bff56721992b9bdb + LocationCustomSoundEvent event = (LocationCustomSoundEvent) _event; + Vector pos = event.getVector(); + return new PacketPlayOutCustomSoundEffect(CraftNamespacedKey.toMinecraft(event.getKey()), SoundCategory.valueOf(event.getCategory().name()), CraftVector.toNMS(pos), volume, pitch); -+ } else { // EntitySoundEvent ++ } else if (_event instanceof EntitySoundEvent) { // EntitySoundEvent + EntitySoundEvent event = (EntitySoundEvent) _event; + return new PacketPlayOutEntitySound(CraftSound.getSoundEffect(event.getSound()), SoundCategory.valueOf(event.getCategory().name()), ((CraftEntity) event.getOrigin()).getHandle(), volume, pitch); + } ++ throw new IllegalArgumentException("Unknown sound event: " + _event.getClass().getName()); + } + // Parchment end }