Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@bd496d0 [ci skip] shuffle patches and rebuild PaperMC/Paper@79f2aa3 Update Velocity natives (#8387) PaperMC/Paper@21661a7 Fix jigsaw block kicking user (#8404) PaperMC/Paper@017af78 [ci skip] Added the missing "d" character (#8267) PaperMC/Paper@8a7dd61 Mark parsed PoiChunks with data as not loaded (#8405) PaperMC/Paper@7d3a882 Do not log throwable for duplicate entity adds PaperMC/Paper@8d69cfc Reduce allocation rate for checkBlock PaperMC/Paper@c6d7375 use BlockFormEvent for mud converting into clay (#8398) PaperMC/Paper@14c32bc Fix wrong yaw and pitch of CommandSourceStack#getBukkitLocation (#8411) PaperMC/Paper@f5fa691 Don't print full packages in new chunk system classes PaperMC/Paper@2534e5c Fix other jigsaw related disconnect bug (#8414) PaperMC/Paper@e9618f8 Add system property to dump stack on bad plugin class access (#8417) PaperMC/Paper@6d14093 Add getDrops to BlockState and isPreferredTool to BlockData (#8284) PaperMC/Paper@ec76e36 Fix a handful of vanilla bugs (#8187) PaperMC/Paper@ec3cfa9 Only create paper.yml-README.txt on config conversion (#8334) PaperMC/Paper@928bcc8 Updated Upstream (Bukkit/CraftBukkit) (#8430) PaperMC/Paper@616db71 Fix nothing mlg (#8432) PaperMC/Paper@011caa4 [ci skip] Minor patch cleanup PaperMC/Paper@15e1748 Avoid resizing of ArrayList in ChunkMap#getPlayers (#8416) PaperMC/Paper@ad3d357 Remove unnecessary onTrackingStart during nav warning PaperMC/Paper@9d63b07 Fix custom piglin interest items (#8097) PaperMC/Paper@ff67f1f EntityPickupItemEvent fixes (#8096) PaperMC/Paper@bcb4220 Correctly handle interactions with items on cooldown (#8008) PaperMC/Paper@60c973e Exempt players in creative/spectator from nether ceiling damage (#8427) PaperMC/Paper@77a50b9 Add Unmodifiable annotations to getDrops methods (#8440) PaperMC/Paper@c389b1c Fix configs that relied on outdated min/max y levels (#6986) PaperMC/Paper@57555b8 Add missing structure set seed configs (#8030) PaperMC/Paper@b097a24 Expose isUnderWater to Entity (#8454) PaperMC/Paper@6b26cfc Add missing Entity + Projectile API (#7632) PaperMC/Paper@de2d2d4 Add PlayerInventorySlotChangeEvent (#7321) PaperMC/Paper@f7c8d79 Fix stacktrace in server tests PaperMC/Paper@b9cf1ac Fix a classloading issue in tests (#8459) PaperMC/Paper@7fe34e9 Make CraftMinecartTNT public PaperMC/Paper@514a606 Elder Guardian appearance API (#8455) PaperMC/Paper@2094011 Update settings directory path in exceptions (#7968) PaperMC/Paper@0bdf997 Avoid cycle deprecation (#8466) PaperMC/Paper@eb68bd4 Allow changing bed's 'occupied' property (#8458) PaperMC/Paper@b560034 Avoid usages of RecipeChoice#getItemStack() (#8453) PaperMC/Paper@603df98 FIx bedrock patterns (#8474) PaperMC/Paper@ec00f99 Fix package for PlayerInventorySlotChangeEvent (#8475) PaperMC/Paper@236a296 Add LivingEntity#swingHand(EquipmentSlot) convenience method (#8456) PaperMC/Paper@7d64d7c Add converted Slot number to PlayerInventorySlotChangeEvent (#8482) PaperMC/Paper@ed2c88b Add LivingEntity knockback API (#8479) PaperMC/Paper@e1d4b26 Fix another case of missing chat headers PaperMC/Paper@f7da209 Fix inconsistent isChunkLoaded calls PaperMC/Paper@3dcfec4 Add stacktrace deobfuscation in more places (#8484) PaperMC/Paper@eb49418 [ci skip] Update workflow dependencies (#8489) PaperMC/Paper@a163a96 Load Allay duplication cooldown as a long (#8410) PaperMC/Paper@7187cab Detect headless JREs (#8491) PaperMC/Paper@60da35e fixed entity vehicle collision event not called (#5053) PaperMC/Paper@5cdb5f9 Optimized dirt and snow spreading (#5124) PaperMC/Paper@3d50709 Add MaterialTags for the different Types of Tools (#8049) PaperMC/Paper@6ea5aa3 Added EntityToggleSitEvent (#7579) PaperMC/Paper@58483c1 Add fire-tick-delay option (#8037) PaperMC/Paper@4e67c73 Add config setting for grindstone overstacking (#8156) PaperMC/Paper@d713b47 Add EquipmentSlot convenience methods (#8477) PaperMC/Paper@6665076 Add Moving Piston API (#7019) PaperMC/Paper@0b8f40c Don't fire EntityToggleSitEvent on deserialization & reorder some api patches (#8495) PaperMC/Paper@05bd9d6 Ignore impossible spawn tick (#8493) PaperMC/Paper@b8131a0 Mark chunks as saved after saving them PaperMC/Paper@44ce9b3 Updated Upstream (Bukkit/Spigot) (#8445) PaperMC/Paper@1c1aeb2 Only limit global sounds to same world if limiting radius (#8499) PaperMC/Paper@519cb4b Move classes added to net.minecraft.server to paper packages (#8500) PaperMC/Paper@fc5ae5b Fix incorrect handling of mustNotSave PaperMC/Paper@25cd3ee Add dirty flag to chunk tick lists PaperMC/Paper@7b3b593 [ci skip] Update checkout action in workflow (#8510) PaperMC/Paper@36869cc Fix new block data in EntityChangeBlockEvent for silverfish when mobGriefing isn't enabled (#8099) PaperMC/Paper@2432233 Add allow server listing & text filtering client options (#7595) PaperMC/Paper@954e6f0 Fix a bunch more forceDrops for dropping items (#8095) PaperMC/Paper@32d95e9 Track projectile source for fireworks from dispensers (#8044) PaperMC/Paper@0249750 Fix EntityArgument suggestion permissions to align with EntitySelector#checkPermissions (#8511) PaperMC/Paper@8acb05d Make CommandSyntaxException implement ComponentMessageThrowable (#8513) PaperMC/Paper@c264018 [ci skip] Undo modification to removed patches in latest commit (#8512) PaperMC/Paper@304ab35 [ci skip] Remove old todo file PaperMC/Paper@8a4b752 Fix wrong descriptor in ASMEventExecutorGenerator (#8506) PaperMC/Paper@b743144 Fix MC-147659 (#8423) PaperMC/Paper@aaf5e39 Deprecate unused VehicleEntityCollisionEvent methods (#8498) PaperMC/Paper@13cf546 Fix pumpkin growth modifier (#8517) PaperMC/Paper@b3b04f2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#8515) PaperMC/Paper@93b2246 Fix EntityCombustEvent cancellation issues (#8529) PaperMC/Paper@4a9c9b3 Build updates PaperMC/Paper@e30b082 Fix setting difficulity inside of API (Fixes #8533) PaperMC/Paper@ebc0f6b Call PlayerLaunchProjectileEvent for trident (#8027) PaperMC/Paper@ab1c072 Remove old redundant fix (#8530) PaperMC/Paper@8ee344f [ci-skip] Rename Paper stop tp Paper end. (#8539) PaperMC/Paper@3d15120 Fix Advancement#getDisplay() api break (#8541) PaperMC/Paper@2b47227 Update Commodore modifications (#8542) PaperMC/Paper@df5fb94 Properly resend entities (#7041) PaperMC/Paper@3e9f39f Prevent compass from loading chunks PaperMC/Paper@3ac1a8d Cleanup misc import from last commit PaperMC/Paper@e6ee4cd Updated Upstream (CraftBukkit) (#8548) PaperMC/Paper@117579c Add PrePlayerAttackEntityEvent (#8369) PaperMC/Paper@112fa18 Show exception when headless JRE detection is triggered (#8559) PaperMC/Paper@5f4952f Cleanup reputation API + back with an EnumMap instead of array (#8258) PaperMC/Paper@564356d ensure reset EnderDragon boss event name (#8562) PaperMC/Paper@7955bcc fix MC-252817 (green map markers do not dissappear) (#8545) PaperMC/Paper@e22dacf update yarn param mappings (#8563) PaperMC/Paper@2151112 Fix/improve Affects Spawning API (#7329) PaperMC/Paper@84b5d4a Reorder bukkit damage source entity for explosion (#8553) PaperMC/Paper@b4c1ae6 Fix MC-121048 (#8429) PaperMC/Paper@825cb43 [ci skip] Add .fleet/ folder to .gitignore (#8574) PaperMC/Paper@669fed4 Fix MC-179072 (#8421) PaperMC/Paper@8f498dc Sync chunk load command improvements (#8554) PaperMC/Paper@3299886 [ci skip] Add TheFruxz to the license MIT list (#8575) PaperMC/Paper@0a6f100 Add more collision code skipping logic (#7581) PaperMC/Paper@76503f8 Strip coordinates from lodestone compasses (#8561) PaperMC/Paper@b95d4b2 Moving ATs from the at file to individual patches (#8573) PaperMC/Paper@4a3ae59 [ci skip] Add check for git repo (#8578) PaperMC/Paper@a7df847 Add Player Warden Warning API (#8470) PaperMC/Paper@3ab194e Avoid a cubed max search distance for POIs (#8576) PaperMC/Paper@55a16d8 Fix Varint21FrameDecoder cached length buf usage PaperMC/Paper@e6e37ba Add api to resolve components (#7648) PaperMC/Paper@7168438 [ci skip] Rework workflows to support optional paperclip build (#8583) PaperMC/Paper@da230d5 More vanilla friendly methods to update trades (#8478) PaperMC/Paper@8aff07a Add /paper dumplisteners command (#8507) PaperMC/Paper@b8919a7 pr command action fixes (#8591) PaperMC/Paper@185fa48 Fix chest relooting mechanics (#8580) PaperMC/Paper@b4beac0 Fixes potential issues arising from optimizing getPlayerByUUID (#8585) PaperMC/Paper@f637b1a Fix async entity add due to fungus trees (#7626) PaperMC/Paper@414ea80 ItemStack damage API (#7801) PaperMC/Paper@d98c370 Add displayName methods for advancements (#8584) PaperMC/Paper@44bb599 Add Tick TemporalUnit (#5445) PaperMC/Paper@9f7eef8 Friction API (#6611) PaperMC/Paper@4048d3e Allow using degrees for ArmorStand rotations (#7847) PaperMC/Paper@f59c802 Schoolable Fish API (#7089) PaperMC/Paper@21b964a Added ability to control player's insomnia and phantoms spawning (#6500) PaperMC/Paper@f1583fc Add `/paper dumplisteners tofile` and increase detail of command output (#8592) PaperMC/Paper@28b4027 Fix packet duplicating at some points (#8566) PaperMC/Paper@309133e Fix preemptive connection dropping during shutdown process (#8546) PaperMC/Paper@8796175 Handle legacy quirk in the console formatter (#8434) PaperMC/Paper@54daefa Fix whitespace error in recent patch PaperMC/Paper@41ab602 [ci skip] couple more fixes for build pr jar label (#8599) PaperMC/Paper@c40f8d5 Sync offhand slot in menus (#7341) PaperMC/Paper@425baed Fully deserialise persistent anger post async load (#8560) PaperMC/Paper@ec6a9a3 Updated Upstream (Bukkit/CraftBukkit) (#8604) PaperMC/Paper@96fdafd Player Entity Tracking Events (#4722) PaperMC/Paper@407a445 Fix dumplisteners missing folder creation PaperMC/Paper@b07d5e0 Limit pet look distance (#8612) PaperMC/Paper@476ef25 Add missing Fluid type (#8608)
277 lines
16 KiB
Diff
277 lines
16 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/gg/projecteden/parchment/event/sound/ParchmentSoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/ParchmentSoundEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..44245b61f64e4e2eb21ac4f5e540aa9a583bfcfe
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/projecteden/parchment/event/sound/ParchmentSoundEvent.java
|
|
@@ -0,0 +1,28 @@
|
|
+package gg.projecteden.parchment.event.sound;
|
|
+
|
|
+import io.papermc.paper.adventure.PaperAdventure;
|
|
+import net.kyori.adventure.sound.Sound;
|
|
+import net.minecraft.sounds.SoundEvent;
|
|
+import net.minecraft.world.entity.Entity;
|
|
+import net.minecraft.world.level.Level;
|
|
+import org.bukkit.Location;
|
|
+
|
|
+import java.util.Optional;
|
|
+import java.util.function.Function;
|
|
+
|
|
+public class ParchmentSoundEvent {
|
|
+ public static final Function<Sound, Double> DISTANCE_FUNCTION = sound -> {
|
|
+ Optional<SoundEvent> soundEvent = PaperAdventure.asVanillaSound(sound.name());
|
|
+ if (soundEvent.isPresent())
|
|
+ return Double.valueOf(soundEvent.get().getRange(sound.volume()));
|
|
+ return gg.projecteden.parchment.event.sound.SoundEvent.DEFAULT_DISTANCE_FUNCTION.apply(sound);
|
|
+ };
|
|
+
|
|
+ public static gg.projecteden.parchment.event.sound.SoundEvent.Emitter createEmitter(Level level, double x, double y, double z) {
|
|
+ return new gg.projecteden.parchment.event.sound.SoundEvent.LocationEmitter(new Location(level.getWorld(), x, y, z));
|
|
+ }
|
|
+
|
|
+ public static gg.projecteden.parchment.event.sound.SoundEvent.Emitter createEmitter(Entity entity) {
|
|
+ return new gg.projecteden.parchment.event.sound.SoundEvent.EntityEmitter(entity.getBukkitEntity());
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
|
index 01e424792f68bac73ec41726031ebbb53df13da7..7fa767185dcc73daa4500b6c66761ea4a19c34b5 100644
|
|
--- a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
|
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
|
@@ -325,6 +325,32 @@ public final class PaperAdventure {
|
|
return asVanilla(source);
|
|
}
|
|
|
|
+ // Parchment start
|
|
+ public static Sound.Source asAdventure(final SoundSource source) {
|
|
+ return switch (source) {
|
|
+ case MASTER -> Sound.Source.MASTER;
|
|
+ case MUSIC -> Sound.Source.MUSIC;
|
|
+ case RECORDS -> Sound.Source.RECORD;
|
|
+ case WEATHER -> Sound.Source.WEATHER;
|
|
+ case BLOCKS -> Sound.Source.BLOCK;
|
|
+ case HOSTILE -> Sound.Source.HOSTILE;
|
|
+ case NEUTRAL -> Sound.Source.NEUTRAL;
|
|
+ case PLAYERS -> Sound.Source.PLAYER;
|
|
+ case AMBIENT -> Sound.Source.AMBIENT;
|
|
+ case VOICE -> Sound.Source.VOICE;
|
|
+ };
|
|
+ }
|
|
+
|
|
+ public static java.util.Optional<net.minecraft.sounds.SoundEvent> asVanillaSound(final Key key) {
|
|
+ return net.minecraft.core.Registry.SOUND_EVENT.getOptional(asVanilla(key));
|
|
+ }
|
|
+
|
|
+ @SuppressWarnings("PatternValidation")
|
|
+ public static Key asAdventure(final ResourceLocation key) {
|
|
+ return Key.key(key.getNamespace(), key.getPath());
|
|
+ }
|
|
+ // Parchment end
|
|
+
|
|
// NBT
|
|
|
|
public static @Nullable BinaryTagHolder asBinaryTagHolder(final @Nullable CompoundTag tag) {
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 79aa3374fd47cd57d2e0810bb5afebbdb38a1892..f4c9ff697bc86e1410e916df19c4eccf05c8af71 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1575,12 +1575,40 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
@Override
|
|
public void playSeededSound(@Nullable Player except, double x, double y, double z, SoundEvent sound, SoundSource category, float volume, float pitch, long seed) {
|
|
- this.server.getPlayerList().broadcast(except, x, y, z, (double) sound.getRange(volume), this.dimension(), new ClientboundSoundPacket(sound, category, x, y, z, volume, pitch, seed));
|
|
+ // Parchment start - sound event
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent(
|
|
+ except == null ? null : except.getBukkitEntity(),
|
|
+ net.kyori.adventure.sound.Sound.sound(
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(sound.getLocation()),
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(category),
|
|
+ volume,
|
|
+ pitch
|
|
+ ),
|
|
+ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(this, x, y, z),
|
|
+ seed,
|
|
+ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.DISTANCE_FUNCTION,
|
|
+ null
|
|
+ ));
|
|
+ // Parchment end
|
|
}
|
|
|
|
@Override
|
|
public void playSeededSound(@Nullable Player except, Entity entity, SoundEvent sound, SoundSource category, float volume, float pitch, long seed) {
|
|
- this.server.getPlayerList().broadcast(except, entity.getX(), entity.getY(), entity.getZ(), (double) sound.getRange(volume), this.dimension(), new ClientboundSoundEntityPacket(sound, category, entity, volume, pitch, seed));
|
|
+ // Parchment start - sound event
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent(
|
|
+ except == null ? null : except.getBukkitEntity(),
|
|
+ net.kyori.adventure.sound.Sound.sound(
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(sound.getLocation()),
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(category),
|
|
+ volume,
|
|
+ pitch
|
|
+ ),
|
|
+ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(entity),
|
|
+ seed,
|
|
+ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.DISTANCE_FUNCTION,
|
|
+ null
|
|
+ ));
|
|
+ // Parchment end
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 9c9b4d7e0637348a94befce9377fdb69c1239694..69b3524ebb197430e90a3519b8165e472e1cf823 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -2250,7 +2250,19 @@ 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, this.random.nextLong()));
|
|
+ // Parchment start - sound event
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent(
|
|
+ null,
|
|
+ net.kyori.adventure.sound.Sound.sound(
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(event.getLocation()),
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(category),
|
|
+ volume,
|
|
+ pitch
|
|
+ ),
|
|
+ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(level, getX(), getY(), getZ()),
|
|
+ this.random.nextLong(), sound -> 0d, soundEvent -> java.util.Collections.singletonList(getBukkitEntity())
|
|
+ ));
|
|
+ // Parchment end
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 3be9352ae9b0b84acf07064b45562ceffd30391b..b0dd96bb3af3ec7157c62c515ac09d8364eef9f5 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -984,7 +984,7 @@ public abstract class PlayerList {
|
|
if (flag2 && !isLocAltered) {
|
|
BlockState data = worldserver1.getBlockState(blockposition);
|
|
worldserver1.setBlock(blockposition, data.setValue(net.minecraft.world.level.block.RespawnAnchorBlock.CHARGE, data.getValue(net.minecraft.world.level.block.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, worldserver1.getRandom().nextLong()));
|
|
+ entityplayer1.playNotifySound(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, 1.0F, 1.0F); // Parchment - use existing play sound method
|
|
// 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 0ea101f155936f7c340d9e1d1077c58b72551027..baa4aa10f40de237d44aa1e692657d2a36eb7a66 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -1917,7 +1917,21 @@ 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 net.minecraft.network.protocol.game.ClientboundSoundPacket(soundEffect, soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong()));
|
|
+ // Parchment start - sound event
|
|
+ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent(
|
|
+ null,
|
|
+ net.kyori.adventure.sound.Sound.sound(
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(soundEffect.getLocation()),
|
|
+ io.papermc.paper.adventure.PaperAdventure.asAdventure(soundCategory),
|
|
+ volume,
|
|
+ pitch
|
|
+ ),
|
|
+ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(fromEntity.level, x, y, z),
|
|
+ fromEntity.random.nextLong(),
|
|
+ sound -> 0d,
|
|
+ soundEvent -> java.util.Collections.singletonList(((ServerPlayer) fromEntity).getBukkitEntity())
|
|
+ ));
|
|
+ // Parchment end
|
|
}
|
|
}
|
|
// 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 6a0a1731fd6804eb69d3641213712d31bce085b2..81819d12e0becde85b6d66f3b3ffedde847a72f6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -526,7 +526,7 @@ public class Raid {
|
|
float f = 13.0F;
|
|
boolean flag = true;
|
|
Collection<ServerPlayer> collection = this.raidEvent.getPlayers();
|
|
- long i = this.random.nextLong();
|
|
+ //long i = this.random.nextLong(); // Parchment - remove redundant variable
|
|
Iterator iterator = this.level.players().iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
@@ -538,7 +538,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, i));
|
|
+ entityplayer.playNotifySound(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, 64.0F, 1.0F); // Parchment - use existing play sound method
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 03b3f29bde2bf6cb4e7b08a775bcc380a9404543..a37bc950d24acee9889aded042ed2bc3a0d76929 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.event;
|
|
|
|
import com.google.common.base.Function;
|
|
import com.google.common.base.Functions;
|
|
-import com.google.common.collect.Lists;
|
|
import com.mojang.datafixers.util.Either;
|
|
import java.net.InetAddress;
|
|
import java.util.ArrayList;
|
|
@@ -1921,4 +1920,52 @@ public class CraftEventFactory {
|
|
return event.callEvent();
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Parchment start
|
|
+ private static net.minecraft.network.protocol.@org.jetbrains.annotations.NotNull Packet<net.minecraft.network.protocol.game.ClientGamePacketListener> handleSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, CraftPlayer recipient) {
|
|
+ // init variables
|
|
+ net.kyori.adventure.sound.Sound sound = event.calculateSound(recipient);
|
|
+ gg.projecteden.parchment.event.sound.SoundEvent.Emitter emitter = event.calculateEmitter(recipient);
|
|
+ net.minecraft.sounds.SoundSource source = io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source());
|
|
+ float volume = sound.volume();
|
|
+ float pitch = sound.pitch();
|
|
+ long seed = event.getSeed();
|
|
+ java.util.Optional<net.minecraft.sounds.SoundEvent> soundEvent = io.papermc.paper.adventure.PaperAdventure.asVanillaSound(sound.name());
|
|
+ // handle vanilla sounds
|
|
+ if (soundEvent.isPresent()) {
|
|
+ if (emitter instanceof gg.projecteden.parchment.event.sound.SoundEvent.EntityEmitter entityEmitter)
|
|
+ return new net.minecraft.network.protocol.game.ClientboundSoundEntityPacket(soundEvent.get(), source, ((CraftEntity) entityEmitter.entity()).getHandle(), volume, pitch, seed);
|
|
+ else if (emitter instanceof gg.projecteden.parchment.event.sound.SoundEvent.LocationEmitter locationEmitter) {
|
|
+ Location loc = locationEmitter.location();
|
|
+ return new net.minecraft.network.protocol.game.ClientboundSoundPacket(soundEvent.get(), source, loc.getX(), loc.getY(), loc.getZ(), volume, pitch, seed);
|
|
+ }
|
|
+ else
|
|
+ throw new IllegalArgumentException("Unknown emitter type: " + emitter.getClass().getName());
|
|
+ }
|
|
+ // handle custom sounds
|
|
+ else {
|
|
+ // warn if trying to use EntityEmitter with custom sound
|
|
+ if (emitter instanceof gg.projecteden.parchment.event.sound.SoundEvent.EntityEmitter)
|
|
+ org.slf4j.LoggerFactory.getLogger("SoundEvent").warn("Sound event is using a custom sound ({}) which cannot be used with EntityEmitter. Falling back to playing at the entity's location.", sound.name().asString());
|
|
+ Vec3 pos = org.bukkit.craftbukkit.util.CraftVector.toNMS(emitter.location().toVector());
|
|
+ return new net.minecraft.network.protocol.game.ClientboundCustomSoundPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.name()), source, pos, volume, pitch, seed);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event) {
|
|
+ org.apache.commons.lang3.Validate.notNull(event, "event");
|
|
+ io.papermc.paper.util.MCUtil.asyncExecutor.execute(() -> {
|
|
+ if (!event.callEvent())
|
|
+ return;
|
|
+ try {
|
|
+ for (Player _player : event.calculateRecipients()) {
|
|
+ CraftPlayer player = (CraftPlayer) _player;
|
|
+ player.getHandle().connection.send(handleSoundEvent(event, player));
|
|
+ }
|
|
+ } catch (Throwable e) {
|
|
+ org.slf4j.LoggerFactory.getLogger("SoundEvent").error("Error playing sound event", e);
|
|
+ }
|
|
+ });
|
|
+ }
|
|
+ // Parchment end
|
|
}
|