Upstream has released updates that appear to apply and compile correctly PaperMC/Paper@42a9c37 Move Adventure patch up PaperMC/Paper@1d7a6a0 Add missing glow_item_frame walkers PaperMC/Paper@f9b05cc Expose furnace minecart push property. (#7548) PaperMC/Paper@9351513 Fix handling message in PlayerHandshakeEvent (#7542) PaperMC/Paper@6564f70 Fix cancelling ProjectileHitEvent for piercing arrows (#7492) PaperMC/Paper@196271d Fix save problems on shutdown PaperMC/Paper@1e12cf8 Add more to the save fixes PaperMC/Paper@a36d7f6 Updated Upstream (CraftBukkit) PaperMC/Paper@7b9c30f Fix scoreboard objective name length limit PaperMC/Paper@d9bf5e7 Add method to set noclip on arrows (#7263) PaperMC/Paper@c34fb09 Add ghast api (#7554) PaperMC/Paper@e0b3f3f Adventure 4.10.1 PaperMC/Paper@718fab1 Add CPU name and JVM vendor info in timings (#7490) PaperMC/Paper@7a21333 Fix setting the view distance to 32 (#7503) PaperMC/Paper@4423e12 Update docs link in paper.yml (#7562) PaperMC/Paper@b55ba19 Update README for new docs (#7561) PaperMC/Paper@657d163 Prevent despawned navigators being readded (#7574) PaperMC/Paper@d714682 Add more entity api (#7564) PaperMC/Paper@1790528 More projectile API (#5731) PaperMC/Paper@ea1efef Remove Patches (#7541) PaperMC/Paper@aab1f8a Fix swamp hut cat generation deadlock PaperMC/Paper@dc96bba Ensure the item sent isn't air (#7584) PaperMC/Paper@bfa33d9 Various improvements to console color formatting (#7560) PaperMC/Paper@87927e1 Fix CreativeCategory API (#7586) PaperMC/Paper@ab03538 Fix colors in some console messages PaperMC/Paper@1358d1e Updated Upstream (CraftBukkit/Spigot) (#7580) PaperMC/Paper@b65b48f [ci skip] Update gradle wrapper PaperMC/Paper@1ce3555 [ci-skip] Fix typo in feature request issue template (#7593) PaperMC/Paper@c8e49cc Add get/set wait time for fish hooks. (#5595) PaperMC/Paper@a5be178 Use correct toX/Y/Z in player move packet handling PaperMC/Paper@0ca80c7 Add getComputedBiome API (#5668) PaperMC/Paper@2d3e8f7 Properly lookup random-ticked precipitation blocks (#7606) PaperMC/Paper@f35a0ce Remove Java version check once and for all (#7612) PaperMC/Paper@1c5f8b0 Updated Upstream (Bukkit/CraftBukkit) (#7604) PaperMC/Paper@f0d0078 Add debug for invalid GameProfiles on skull blocks/items (#7512) PaperMC/Paper@8788bf7 fix datapacks not being able to modify nether/end (#7588) PaperMC/Paper@b8c90d2 Added method to check snapshot state of TileStates (#7325) PaperMC/Paper@8897cea Add enchantWithLevels API (#7615) PaperMC/Paper@2eeca6f Fix world saving in unloadWorld PaperMC/Paper@319d5fa Fix state locking for getTopMRUProfiles & getProfileIfCached PaperMC/Paper@bc68ee0 Remove redundant GameProfileCache diff PaperMC/Paper@855637f Updated Upstream (CraftBukkit) (#7624) PaperMC/Paper@5eb61dd Buffer OOB setBlock calls PaperMC/Paper@7b46444 Properly create profiles with custom name/uuid (#7558) PaperMC/Paper@a686ff5 Add more missing entity API (#7592) PaperMC/Paper@993f828 Add TameableDeathMessageEvent (#5392) PaperMC/Paper@a939d6e Fix generator settings string for flat-type worlds (#7568) PaperMC/Paper@ab666a4 Deprecating remaining blockkey methods (#7638) PaperMC/Paper@e7d928a Fix EntityChangeBlockEvent#getBlockData for when sheep eats grass block (#7646) PaperMC/Paper@e2f743d Fix PalettedContainer synchronization (#7663) PaperMC/Paper@7fa8870 Updated Upstream (Bukkit/CraftBukkit) (#7672) PaperMC/Paper@fa68bb1 Fix entity position desync for hanging entities (#7659) PaperMC/Paper@d3c1023 fix player loottables running when mob loot gamerule is false (#7651) PaperMC/Paper@7f47b9b Remove KeyedObject interface (#7680) PaperMC/Paper@7bf9446 Add per player chunk loading limits PaperMC/Paper@04c7b16 Undeprecate Material#isLegacy (#7679) PaperMC/Paper@443c506 Fix Nullability Annotations for PrepareItemEnchantEvent (#7681) PaperMC/Paper@ea2c81e Fix lectern quick move PaperMC/Paper@87e11bf Cache resource keys instead of trying to create them (#7643) PaperMC/Paper@820e9ca Update decompiler & param mappings PaperMC/Paper@92426e3 Update Gradle wrapper PaperMC/Paper@62dcff3 Update actions PaperMC/Paper@2914457 Allow seting custom podium location for ender dragon (#7695) PaperMC/Paper@11e0dcd Fix NBT pieces overriding a block entity during worldgen deadlock (#7692) PaperMC/Paper@2f16393 Updated Upstream (CraftBukkit) PaperMC/Paper@4322c05 Use patched spigot decompiler (#7706) PaperMC/Paper@f8e8d6c Strip enderpearl owners when they are no longer ticked (#7559) PaperMC/Paper@e42d683 Fix StructureGrowEvent species for RED_MUSHROOM PaperMC/Paper@a9ee104 Prevent tile entity copies loading chunks PaperMC/Paper@d4a712d [CI-SKIP] Remove unused import from last patch PaperMC/Paper@a9f252e Replace third party repos with Paper repo (#7733) PaperMC/Paper@b8fa41e [ci skip] Remove Mojang repo from test-plugin PaperMC/Paper@c6e631a Use username instead of display name in PlayerList#getPlayerStats (#7740) PaperMC/Paper@1cfd363 Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@af94364 Fix slime spawners not spawning outside slime chunks (#7741) PaperMC/Paper@6b9f7a0 Don't fire worldborder events for virtual borders (#7749) PaperMC/Paper@8bfb1d2 Pass ServerLevel for gamerule callbacks (#7668) PaperMC/Paper@c66b0f9 Add pre-unbreaking amount to PlayerItemDamageEvent (#7724) PaperMC/Paper@86fb3d2 Don't send itemmeta for books with the hide option enabled (#7734) PaperMC/Paper@c642d25 Improve update folder behavior (#7687) PaperMC/Paper@c7d4c01 Ignore invalid jars inside of the updates folder (Fixes #7751) PaperMC/Paper@4ecc338 WorldCreator#keepSpawnLoaded (#7673) PaperMC/Paper@873bfa6 Remove World#refreshChunk deprecation (#7684) PaperMC/Paper@76ed156 Grant temporary immunity from EAR to moving entities (Fixes #7637) (#7644) PaperMC/Paper@567fce6 Don't apply previous potion when item is potion (fixes #7756) (#7757) PaperMC/Paper@c449f6a Build updates PaperMC/Paper@ef6a1a5 Revert to old createProfile(UUID, String) logic (#7723) PaperMC/Paper@0f8aa4e Fix NPE for BlockDataMeta#getBlockData (#7670) PaperMC/Paper@16f224a Trigger bee_nest_destroyed trigger in the correct place (#7436) PaperMC/Paper@caf4a6f Remove or replace a few dumb deprecations (#7760) PaperMC/Paper@47f43da Add missing javadoc deprecation msgs for PlayerProfile (#7688) PaperMC/Paper@fbbc03a Add EntityDyeEvent and CollarColorable interface (#7625) PaperMC/Paper@5b85ee3 Fire CauldronLevelChange on initial fill (#7678) PaperMC/Paper@4dc78ae Fix some team color docs and added hasColor (#7602) PaperMC/Paper@0bf7c95 Fix opening inv in PlayerRecipeBookClickEvent handler (#7552) PaperMC/Paper@d70ac03 fix powder snow cauldrons not turning to water (#7229) PaperMC/Paper@ce059b4 Fix V1451 dataconverter stat types PaperMC/Paper@6f5e6c6 Use setMessage instead of arraycopy PaperMC/Paper@608482d cleanup filtered sign text (#7777) PaperMC/Paper@4166632 Updated Upstream (Bukkit/CraftBukkit) (#7776) PaperMC/Paper@e564110 Couple fixes/improvements to PlayerSetSpawnEvent (#6754) PaperMC/Paper@e5da93a Deprecate duplicate SoundGroup API (#7509) PaperMC/Paper@2ab0258 Use mojang item ids for alternative item despawn rate (#6997) PaperMC/Paper@f6a69de Undeprecate getOfflinePlayer (#7773) PaperMC/Paper@a117da6 Add PlayerStopUsingItemEvent (#7787) PaperMC/Paper@f3a8a0b FallingBlock auto expire setting (#7037) PaperMC/Paper@4219389 Don't tick markers (#7299) PaperMC/Paper@2515bc4 Improve configurable door difficulty (#6985) PaperMC/Paper@8c9d98e Clean unused field for Configurable door breaking difficulty (#7793) PaperMC/Paper@b831784 Only log for passenger / vehicle world mismatch PaperMC/Paper@7a6163b Add Alternate Current's redstone implementation as an alternative to Vanilla and Eigencraft's. (#7701) PaperMC/Paper@1a17a83 Move redstone config changes to Eigencraft patch PaperMC/Paper@87d2eb2 Fix door breaking difficulty defaults for vindicator (#7795) PaperMC/Paper@e399754 Do not accept invalid client settings PaperMC/Paper@268476b Fix whitespace error in Alternate Current patch PaperMC/Paper@18f0f8d Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@5928327 Remove unneeded patch (#7806) PaperMC/Paper@9fd870d Fix cancelling PlayerItemFrameChangeEvent (#7761) PaperMC/Paper@8d1de8d deprecate old MaterialData api (#7585) PaperMC/Paper@0116751 List world on tile entity placement exception (#7709) PaperMC/Paper@73bd35d Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@7045f18 Change link to screamingsandals PaperMC/Paper@ca62386 Hide ores with deepslate at Y=4 and below (#7792) PaperMC/Paper@9b492cf Deprecate set/doesBounce from Projectile (#7800) PaperMC/Paper@ed4e916 [ci-skip] Update repository and API urls (#7835) PaperMC/Paper@fc1752f Fix more upstream javadocs (#7837) PaperMC/Paper@123cad5 Remove incorrect parent perm from debugstick.always (#7846) PaperMC/Paper@d8108b5 team color parameter may be null, causing NPE PaperMC/Paper@31ccc57 Add support for Proxy Protocol (#7710) PaperMC/Paper@a90092e Updated Upstream (CraftBukkit/Spigot) (#7848) PaperMC/Paper@79e07f3 Fix addPassenger for Marker (#7762) PaperMC/Paper@182a609 Fix duplicate world keys via createWorld (#7614) PaperMC/Paper@b6a6544 Provide ComponentSerializer services (#7527) PaperMC/Paper@3f7fbe3 Fix cb's janky level name in WorldCreator (#7851) PaperMC/Paper@af3b377 Update ForgeFlower (#7857) PaperMC/Paper@9667181 Fix OfflinePlayer#getBedSpawnLocation (#7861) PaperMC/Paper@c123915 Fix FurnaceInventory for smokers and blast furnaces (#7249) PaperMC/Paper@f7382f5 Remove unneeded UOE when copying biome sources (#7629) PaperMC/Paper@6b035fd Update default vanilla command perms (#7386) PaperMC/Paper@f210f67 Update the rewriteForIde for new cb package version (#7242) PaperMC/Paper@3f7111d Fix EntityEquipment and related javadocs (#7380) PaperMC/Paper@78e6431 Add default kick msg component (#6886) PaperMC/Paper@04e1b07 Check HAProxyMessage type is PROXY (#7864) PaperMC/Paper@00c6ae8 Implement Translatable on CreativeCategory (#7587) PaperMC/Paper@7602dd2 Sanitize Sent BlockEntity NBT (#7010) PaperMC/Paper@2d17a50 Add translation keys to GameMode enum (#7081) PaperMC/Paper@c5caee3 Prevent entity loading causing async lookups (#7553) PaperMC/Paper@71fe3c6 Add numeric string completion suggestions as int suggestions (#6360) PaperMC/Paper@b1ac25f Respect x-ray permission in World#refreshChunk (#7214) PaperMC/Paper@1d08ce8 Disable book selector resolving by default PaperMC/Paper@80d5e71 Updated Upstream (Bukkit) PaperMC/Paper@2033dba Updated Upstream (CraftBukkit) PaperMC/Paper@a3ad720 Remove ChatColor usages (#7543) PaperMC/Paper@8fc0999 Fix some nullability things (#7275) PaperMC/Paper@fd069dd Remove incorrect throws javadoc in Team (#7869) PaperMC/Paper@bed5cb2 Limit resolved selectors when enabled PaperMC/Paper@4d83ed0 [ci skip] Changing the order of the rebase with autosquash command in the contributing.md (#6974) PaperMC/Paper@071a4a2 throw exception if worlds are created while being ticked (#7653) PaperMC/Paper@5b6397a Make leave messages for kicks the same as for quitting (#7874) PaperMC/Paper@5befb55 Updated Upstream (Bukkit/CraftBukkit) (#7875) PaperMC/Paper@b3deb25 Move some methods to RegionAccessor (#7635) PaperMC/Paper@d8ef841 [DataConverter] Fix generator options parsing PaperMC/Paper@4b27254 Fix treasure maps discovered settings (#7627) PaperMC/Paper@276d830 Fix campfire walker in V1920 PaperMC/Paper@3925a53 Make timings link clickable (#7944)
169 lines
12 KiB
Diff
169 lines
12 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: lexikiq <noellekiq@gmail.com>
|
|
Date: Sat, 19 Jun 2021 16:30:39 -0400
|
|
Subject: [PATCH] Add SoundEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 98209532ad3e692d7e459640123f78bbd9a65889..53f5e22370f3bc0d29cc38641d67e869305ced86 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1520,12 +1520,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
@Override
|
|
public void playSound(@Nullable Player except, double x, double y, double z, SoundEvent sound, SoundSource category, float volume, float pitch) {
|
|
- this.server.getPlayerList().broadcast(except, x, y, z, volume > 1.0F ? (double) (16.0F * volume) : 16.0D, this.dimension(), new ClientboundSoundPacket(sound, category, x, y, z, volume, pitch));
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.LocationNamedSoundEvent(null, getWorld(), new org.bukkit.util.Vector(x, y, z), org.bukkit.craftbukkit.CraftSound.getBukkit(sound), org.bukkit.SoundCategory.valueOf(category.name()), volume, pitch), this.server, volume > 1.0F ? (double) (16.0F * volume) : 16.0D); // Parchment
|
|
}
|
|
|
|
@Override
|
|
public void playSound(@Nullable Player except, Entity entity, SoundEvent sound, SoundSource category, float volume, float pitch) {
|
|
- this.server.getPlayerList().broadcast(except, entity.getX(), entity.getY(), entity.getZ(), volume > 1.0F ? (double) (16.0F * volume) : 16.0D, this.dimension(), new ClientboundSoundEntityPacket(sound, category, entity, volume, pitch));
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.EntitySoundEvent(null, entity.getBukkitEntity(), org.bukkit.craftbukkit.CraftSound.getBukkit(sound), org.bukkit.SoundCategory.valueOf(category.name()), volume, pitch), this.server, volume > 1.0F ? (double) (16.0F * volume) : 16.0D); // Parchment
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index a6edf5117d4ae03d8294e7bb74dd2d77048895a5..0f29fd8768d4443211e85c96f624c12d60f488da 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -2195,7 +2195,7 @@ public class ServerPlayer extends Player {
|
|
|
|
@Override
|
|
public void playNotifySound(SoundEvent event, SoundSource category, float volume, float pitch) {
|
|
- this.connection.send(new ClientboundSoundPacket(event, category, this.getX(), this.getY(), this.getZ(), volume, pitch));
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.LocationNamedSoundEvent(getBukkitEntity(), org.bukkit.craftbukkit.CraftSound.getBukkit(event), org.bukkit.SoundCategory.valueOf(category.name()), volume, pitch), this); // Parchment
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 624946f48f0811c94d05174f28d0b1fc6d5e6a00..ebc22dc4729146f9e28830a64204daf0084018a3 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -974,7 +974,7 @@ public abstract class PlayerList {
|
|
if (flag2 && !isLocAltered) {
|
|
BlockState data = worldserver1.getBlockState(blockposition);
|
|
worldserver1.setBlock(blockposition, data.setValue(RespawnAnchorBlock.CHARGE, data.getValue(RespawnAnchorBlock.CHARGE) - 1), 3);
|
|
- entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) location.getX(), (double) location.getY(), (double) location.getZ(), 1.0F, 1.0F));
|
|
+ entityplayer1.playNotifySound(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, 1.0F, 1.0F); // Parchment
|
|
// Paper end
|
|
}
|
|
// Added from changeDimension
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 2483d7df7f1bf94344afd38b37602c645a4a2dff..ef8038587117829c84a237a52498496cd39ab91a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -1849,7 +1849,7 @@ public abstract class Player extends LivingEntity {
|
|
private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) {
|
|
fromEntity.level.playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity himself
|
|
if (fromEntity instanceof ServerPlayer) {
|
|
- ((ServerPlayer) fromEntity).connection.send(new ClientboundSoundPacket(soundEffect, soundCategory, x, y, z, volume, pitch));
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.LocationNamedSoundEvent(fromEntity.getBukkitEntity(), new org.bukkit.util.Vector(x, y, z), org.bukkit.craftbukkit.CraftSound.getBukkit(soundEffect), org.bukkit.SoundCategory.valueOf(soundCategory.name()), volume, pitch), (ServerPlayer) fromEntity); // Parchment
|
|
}
|
|
}
|
|
// Paper end
|
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
index f50abfd058e3adf1cf8c0f4468a60bc04e8541e7..2ff60e8fa65626a9805597776b9163fd40e6807d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -26,7 +26,7 @@ import net.minecraft.nbt.ListTag;
|
|
import net.minecraft.nbt.NbtUtils;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.TranslatableComponent;
|
|
-import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
|
+//import net.minecraft.network.protocol.game.ClientboundSoundPacket; // Parchment
|
|
import net.minecraft.server.level.ServerBossEvent;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
@@ -537,7 +537,7 @@ public class Raid {
|
|
double d2 = vec3d.z + 13.0D / d0 * (vec3d1.z - vec3d.z);
|
|
|
|
if (d0 <= 64.0D || collection.contains(entityplayer)) {
|
|
- entityplayer.connection.send(new ClientboundSoundPacket(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, d1, entityplayer.getY(), d2, 64.0F, 1.0F));
|
|
+ entityplayer.playNotifySound(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, 64.0F, 1.0F); // Parchment
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index ceacb62aef0dd0f73f1542a1898ceb62c3f4c367..70d445429fec455f8188341ffd401e83f6bdab1c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1917,4 +1917,77 @@ public class CraftEventFactory {
|
|
return event.callEvent();
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Parchment start
|
|
+ private static net.minecraft.network.protocol.Packet<net.minecraft.network.protocol.game.ClientGamePacketListener> handleSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent _event) {
|
|
+ if (!_event.callEvent()) {
|
|
+ return null;
|
|
+ } else {
|
|
+ float volume = _event.getVolume();
|
|
+ float pitch = _event.getPitch();
|
|
+ net.minecraft.sounds.SoundSource source = net.minecraft.sounds.SoundSource.valueOf(_event.getCategory().name());
|
|
+
|
|
+ if (_event instanceof gg.projecteden.parchment.event.sound.NamedSoundEvent namedSoundEvent) {
|
|
+ net.minecraft.sounds.SoundEvent sound = org.bukkit.craftbukkit.CraftSound.getSoundEffect(namedSoundEvent.getSound());
|
|
+
|
|
+ if (_event instanceof gg.projecteden.parchment.event.sound.LocationNamedSoundEvent event) {
|
|
+ org.bukkit.util.Vector pos = event.getVector();
|
|
+ return new net.minecraft.network.protocol.game.ClientboundSoundPacket(sound, source, pos.getX(), pos.getY(), pos.getZ(), volume, pitch);
|
|
+ } else {
|
|
+ gg.projecteden.parchment.event.sound.EntitySoundEvent event = (gg.projecteden.parchment.event.sound.EntitySoundEvent) _event;
|
|
+ return new net.minecraft.network.protocol.game.ClientboundSoundEntityPacket(sound, source, ((CraftEntity) event.getOrigin()).getHandle(), volume, pitch);
|
|
+ }
|
|
+ } else {
|
|
+ gg.projecteden.parchment.event.sound.LocationCustomSoundEvent event = (gg.projecteden.parchment.event.sound.LocationCustomSoundEvent) _event;
|
|
+ org.bukkit.util.Vector pos = event.getVector();
|
|
+ return new net.minecraft.network.protocol.game.ClientboundCustomSoundPacket(CraftNamespacedKey.toMinecraft(event.getKey()), source, org.bukkit.craftbukkit.util.CraftVector.toNMS(pos), volume, pitch);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, java.util.function.Consumer<net.minecraft.network.protocol.Packet<net.minecraft.network.protocol.game.ClientGamePacketListener>> soundPlayer) {
|
|
+ org.apache.commons.lang3.Validate.notNull(event, "event");
|
|
+ org.apache.commons.lang3.Validate.notNull(soundPlayer, "soundPlayer");
|
|
+ if (!(event instanceof gg.projecteden.parchment.event.sound.LocationNamedSoundEvent || event instanceof gg.projecteden.parchment.event.sound.LocationCustomSoundEvent || event instanceof gg.projecteden.parchment.event.sound.EntitySoundEvent)) {
|
|
+ throw new IllegalArgumentException("Unknown sound event: " + event.getClass().getName());
|
|
+ }
|
|
+ java.util.concurrent.CompletableFuture.supplyAsync(() -> handleSoundEvent(event), net.minecraft.server.MCUtil.asyncExecutor).thenAcceptAsync(packet -> {
|
|
+ if (packet != null)
|
|
+ soundPlayer.accept(packet);
|
|
+ }, net.minecraft.server.MCUtil.asyncExecutor);
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, CraftPlayer sendTo) {
|
|
+ playSoundEvent(event, sendTo.getHandle());
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, ServerPlayer sendTo) {
|
|
+ playSoundEvent(event, sendTo.connection);
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, net.minecraft.server.network.ServerPlayerConnection sendTo) {
|
|
+ playSoundEvent(event, sendTo::send);
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, net.minecraft.server.MinecraftServer server, double radius) {
|
|
+ playSoundEvent(event, server.getPlayerList(), radius);
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, net.minecraft.server.players.PlayerList playerList, double radius) {
|
|
+ final net.minecraft.world.entity.player.Player player = event.getPlayer() == null ? null : ((org.bukkit.craftbukkit.entity.CraftHumanEntity) event.getPlayer()).getHandle();
|
|
+ final net.minecraft.resources.ResourceKey<Level> world = ((CraftWorld) event.getWorld()).getHandle().dimension();
|
|
+ final org.bukkit.util.Vector pos;
|
|
+ if (event instanceof gg.projecteden.parchment.HasLocation hasLoc) {
|
|
+ pos = hasLoc.getLocation().toVector();
|
|
+ } else if (event instanceof gg.projecteden.parchment.event.sound.EntitySoundEvent entityEvent) {
|
|
+ pos = entityEvent.getOrigin().getLocation().toVector();
|
|
+ } else {
|
|
+ throw new IllegalArgumentException("Could not determine location of sound event");
|
|
+ }
|
|
+ final double posX = pos.getX();
|
|
+ final double posY = pos.getY();
|
|
+ final double posZ = pos.getZ();
|
|
+ playSoundEvent(event, packet -> playerList.broadcast(player, posX, posY, posZ, radius, world, packet));
|
|
+ }
|
|
+ // Parchment end
|
|
}
|