Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@c2e2281 Initial 1.18 update PaperMC/Paper@12efc3f Fixes PaperMC/Paper@60af9b0 moar fixes PaperMC/Paper@19f9520 1.18.2 compiles successfuly now PaperMC/Paper@f4eb08a Readd 'Fix entity type tags suggestions in selectors' PaperMC/Paper@706c98a Update Datafixer PaperMC/Paper@02e2402 Update README PaperMC/Paper@c984991 Fix mc dev fix by removing it PaperMC/Paper@490517d fixed flat bedrock patch PaperMC/Paper@9da236f re-add config for stronghold seed patch PaperMC/Paper@9a73213 Adventure 4.10.0 PaperMC/Paper@37436ac Move comment up PaperMC/Paper@c6fc144 Fix unload stall PaperMC/Paper@fbe43d6 clean up patch changes PaperMC/Paper@3526f22 move patch relying on TraceUtil to after its creation PaperMC/Paper@fd74326 update reobf-mappings-patch.tiny PaperMC/Paper@5071d50 clean up view distance api diff PaperMC/Paper@cc45a35 move decompile fixes to start of git history PaperMC/Paper@146ac7b address failing mob goals test PaperMC/Paper@b9037a5 fix issue resulting from kenny's apatch addiction PaperMC/Paper@126ca73 Add TODO for leaf PaperMC/Paper@ab8a139 Configure javadoc overview and doc-files copying PaperMC/Paper@0859f59 1_18_R2 PaperMC/Paper@14add2b Updated Upstream (CraftBukkit) PaperMC/Paper@178802a Fix various 1.18.2 update issues (#7523) PaperMC/Paper@b1afebb Force close world loading screen on join (#7529) PaperMC/Paper@d3caeeb Fix early registry access in xray patch PaperMC/Paper@c6ea84c Drop unneeded desync patch PaperMC/Paper@12d89fe Revert chunk postprocessing back to 1.18.1 logic PaperMC/Paper@90788a5 clean up prepareTickingChunk diff PaperMC/Paper@d33cdcf Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@753bf2c Update paperweight to 1.3.5 PaperMC/Paper@15b6b3d Add StructuresLocateEvent as replacement for StructureLocateEvent (#7524) PaperMC/Paper@c09365a Fix deadlock on watchdog crash (#7535) PaperMC/Paper@719daa8 Updated Upstream (CraftBukkit) PaperMC/Paper@b9f26bb Add printPaperVersion task PaperMC/Paper@63aa4d3 Clarify exception messages for invalid view distances (#7510) PaperMC/Paper@0ee6dda Add javadoc linking for adventure-text-minimessage (#7538) PaperMC/Paper@b6616c8 Fix falling block spawn methods PaperMC/Paper@6d47843 replace bungeecord-chat dependency with deprecated version (#7539) PaperMC/Paper@42a9c37 Move Adventure patch up
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 b5b56d4549e97abbbe9e91d881b9bca8428f1eec..1f0624e96f17fd16658dc244aaf15d56da8243ab 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1510,12 +1510,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 e74c13e7aaa144fcd07036de70e80bebf0be698a..397d2c48c57a58c32b96c712d1c9682ac7dd0b87 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -2187,7 +2187,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 02dc93c394d37c9a84aa4a58d80615c403c54fb9..85d6690bf0a96654a4fb596a8e5d8e1afc01bbc5 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 9c767096ca950d55d6002282c7a3fe2884bcd630..c4db8912d3af42cc4da825e8b43f3fdf4d49e1b5 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -1846,7 +1846,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 a3c8a0291fa9ae6f3c96d937dd4621edd7c48535..d2a1368eeff0704760432166e0910343512bbe4f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1919,4 +1919,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
|
|
}
|