diff --git a/build.gradle.kts b/build.gradle.kts index 90f8ef0..741ec55 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { java `maven-publish` id("com.github.johnrengelman.shadow") version "7.1.2" apply false - id("io.papermc.paperweight.patcher") version "1.3.6" + id("io.papermc.paperweight.patcher") version "1.3.7" } repositories { @@ -16,7 +16,7 @@ repositories { dependencies { remapper("net.fabricmc:tiny-remapper:0.8.2:fat") - decompiler("net.minecraftforge:forgeflower:1.5.498.12") + decompiler("net.minecraftforge:forgeflower:1.5.605.7") paperclip("io.papermc:paperclip:3.0.2") } @@ -79,13 +79,13 @@ tasks.generateDevelopmentBundle { apiCoordinates.set("gg.projecteden.parchment:parchment-api") mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi") libraryRepositories.set( - listOf( - "https://repo.maven.apache.org/maven2/", - "https://libraries.minecraft.net/", - "https://papermc.io/repo/repository/maven-public/", - "https://maven.quiltmc.org/repository/release/", - "https://sonatype.projecteden.gg/repository/maven-public/" - ) + listOf( + "https://repo.maven.apache.org/maven2/", + "https://libraries.minecraft.net/", + "https://papermc.io/repo/repository/maven-public/", + "https://maven.quiltmc.org/repository/release/", + "https://sonatype.projecteden.gg/repository/maven-public/" + ) ) } diff --git a/gradle.properties b/gradle.properties index 21920f4..e50168c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group = gg.projecteden.parchment -version = 1.18.2-R0.1-SNAPSHOT +version = 1.19-R0.1-SNAPSHOT -mcVersion = 1.18.2 -paperRef = 3925a53dd0fbe6bb99c15228b618dddd67017dcd +mcVersion = 1.19 +paperRef = e4f5e1c9ab867701eb4b3347280ad2dc099b7db0 org.gradle.caching=true org.gradle.parallel=true diff --git a/patches/api/0001-Add-Getter-interfaces.patch b/patches/api/0001-Add-Getter-interfaces.patch index 4e2c1a6..5b2cc47 100644 --- a/patches/api/0001-Add-Getter-interfaces.patch +++ b/patches/api/0001-Add-Getter-interfaces.patch @@ -60,7 +60,7 @@ index abeb24fccda2acfdb0dfdadacb8fe688bd97cf78..890069604ca78a9a3f3b4c5f40969a45 private boolean cancelled = false; @NotNull private final Location location; diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java -index a79aa4834e700f845a625e9ab15760690726e81c..fd51dfa9218065b2ace87a92eedf4ec4584a7393 100644 +index 59ae7bc3a0a2079fe4b3a92d777aca682a58e4e3..6aac09818b847ca6b25514a109f9b0e902840167 100644 --- a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java @@ -20,7 +20,7 @@ import java.util.UUID; @@ -115,10 +115,10 @@ index 4dcf6242c9acc62d030a94f67b78729ed29f8c85..d09aecb0b45f2ccf9badd308ef3e472b /** * Sets the UUID for this player name. This will skip the initial API call to find the players UUID. diff --git a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java -index 4cd97cb102e1ec53b3fe1a451b65b4b640fde099..871ff8bae4ac50049a6e23a0cd1263121f8fbad1 100644 +index 9be64a95c2345433b6142d611077dedadcef9f5d..e3cea810881868fb5869de72f331733e6893fcee 100644 --- a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java -@@ -48,7 +48,7 @@ import org.jetbrains.annotations.Nullable; +@@ -47,7 +47,7 @@ import org.jetbrains.annotations.Nullable; * * Only 1 process will be allowed to provide completions, the Async Event, or the standard process. */ @@ -593,7 +593,7 @@ index ef0cb00ca4cb7d2f5e4ec1c950cce036566d1ae4..df53183beb4c438ea3c821e1ffd8e271 * Sets the world that this location resides in * diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java -index 23e853bae0e051cd43deb9eb24c54e74a56d8ab0..20cb99c906725ba3a67d2a71338ba8cacfe5072c 100644 +index a7d1f1e701f23e851f735584a30bedadb0d8b9bd..7b37b6f596b4ac6b8049c7bd195139ac03ba63bc 100644 --- a/src/main/java/org/bukkit/OfflinePlayer.java +++ b/src/main/java/org/bukkit/OfflinePlayer.java @@ -10,7 +10,7 @@ import org.bukkit.profile.PlayerProfile; @@ -633,10 +633,10 @@ index 983a8c20a06d2b509602b27f49c090598b8ecc42..46dd8496f5a2c792ee7811e33c424e88 /** * Get whether this raid started. diff --git a/src/main/java/org/bukkit/Vibration.java b/src/main/java/org/bukkit/Vibration.java -index 8d568d21fcbf706f55cda087bd7222ac60889c0a..8bc5b7a0df5c8f5e5d973c2d2b348968f5b759b2 100644 +index 209a302c3a2ed333780ed760314a6ed352fc0767..9d29f1c5af56954bc452fa251d6bc0215ab3fe79 100644 --- a/src/main/java/org/bukkit/Vibration.java +++ b/src/main/java/org/bukkit/Vibration.java -@@ -64,7 +64,7 @@ public class Vibration { +@@ -74,7 +74,7 @@ public class Vibration { } } @@ -646,7 +646,7 @@ index 8d568d21fcbf706f55cda087bd7222ac60889c0a..8bc5b7a0df5c8f5e5d973c2d2b348968 private final Location block; diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java -index ff8f1231f3e2e71740fd24fa8d4dac5d0e550ae7..ee19d7fd5bb1851af39320f1edd858e1f7bdd1cc 100644 +index d124768378d6f0c5573f28ee815ea3886fe74868..e790878186b64422dc4a3f52f4c7611441c82589 100644 --- a/src/main/java/org/bukkit/attribute/AttributeModifier.java +++ b/src/main/java/org/bukkit/attribute/AttributeModifier.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; @@ -724,7 +724,7 @@ index 8bc6876c82935988436597161fa0ec94c032174b..ffd5fbc3e14be5439f1334c567b573c3 /** * Gets the entity's current position diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java -index e8b6cfe7e454c666b4d60b702a3b211dab238830..b9196b22e5bf4dea7466d6a691f93969a2c72843 100644 +index 5dbbeb92aec212d2e849d16320ed9c084b99fc35..32e5150b14f5d7d19d82d15631065db376814e25 100644 --- a/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java @@ -19,7 +19,15 @@ import org.jetbrains.annotations.Nullable; @@ -1109,10 +1109,10 @@ index 128e43cf12205f82f2b119a773208502cdccfdd4..ca1fed3081e2b0a3271a2dfa0f49cce7 private static final HandlerList handlers = new HandlerList(); // diff --git a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java -index f96c4ba53ab41ea66d4f9a4d54eeabb63f992b58..fdc3114adb18108ccd8acbab458bacededed4767 100644 +index 4a3451af454295ac3e1b688e6665cad9fc594c82..b88cebb219577d59cc338be89c6f391d10702095 100644 --- a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java +++ b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java -@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; +@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull; * advised to ensure the client does not have permission for the relevant * commands, or use {@link PlayerCommandSendEvent}. */ @@ -1122,7 +1122,7 @@ index f96c4ba53ab41ea66d4f9a4d54eeabb63f992b58..fdc3114adb18108ccd8acbab458baced private static final HandlerList handlers = new HandlerList(); // diff --git a/src/main/java/org/bukkit/event/world/GenericGameEvent.java b/src/main/java/org/bukkit/event/world/GenericGameEvent.java -index 1746b66510e7b9c8708018582034b04714c29867..9c1c1acb91fc36e8811c27f7a6d8347249d95c16 100644 +index 2a2a329877d8da45c2d6afecf78ce88d52635cad..22cdf3662b02fb5751ac6d913d781084cd7eee5b 100644 --- a/src/main/java/org/bukkit/event/world/GenericGameEvent.java +++ b/src/main/java/org/bukkit/event/world/GenericGameEvent.java @@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable; @@ -1174,7 +1174,7 @@ index 2448e70d75ae7a678c6befac4506c103edb78875..65ca144618f74bc8e317a4b9c2732ad5 /** * Represents various extra properties of certain inventory windows. diff --git a/src/main/java/org/bukkit/loot/LootContext.java b/src/main/java/org/bukkit/loot/LootContext.java -index e307f9fc45a4e5d742b78c4cda9a41d7f259a515..a66d59321915b0dc76f8e2dd95f01f9e3adaefa6 100644 +index 71b7aa9d675e1714e286e6fd4015ead036d912e0..95e120068a7c5c96b1b8553df9cf8654ba63a325 100644 --- a/src/main/java/org/bukkit/loot/LootContext.java +++ b/src/main/java/org/bukkit/loot/LootContext.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable; diff --git a/patches/api/0002-Add-SoundEvent.patch b/patches/api/0002-Add-SoundEvent.patch index 2fcc353..9fc1bac 100644 --- a/patches/api/0002-Add-SoundEvent.patch +++ b/patches/api/0002-Add-SoundEvent.patch @@ -4,383 +4,313 @@ Date: Sat, 19 Jun 2021 22:55:10 -0400 Subject: [PATCH] Add SoundEvent -diff --git a/src/main/java/gg/projecteden/parchment/event/sound/EntitySoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/EntitySoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..5b74910e441a943597d3170ff00a9b9debab1d38 ---- /dev/null -+++ b/src/main/java/gg/projecteden/parchment/event/sound/EntitySoundEvent.java -@@ -0,0 +1,49 @@ -+package gg.projecteden.parchment.event.sound; -+ -+import org.apache.commons.lang.Validate; -+import org.bukkit.Sound; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.Entity; -+import org.bukkit.entity.HumanEntity; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+/** -+ * Called when an entity sound is sent to a player. Cancelling this event will prevent the packet from sending. -+ *

-+ * This type of sound represents one that will follow the {@link #origin} entity. -+ */ -+public class EntitySoundEvent extends NamedSoundEvent { -+ private @NotNull Entity origin; -+ -+ public EntitySoundEvent(@Nullable HumanEntity receiver, @NotNull Entity origin, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ super(receiver, sound, category, volume, pitch); -+ Validate.notNull(origin, "origin cannot be null"); -+ this.origin = origin; -+ } -+ -+ /** -+ * Gets the entity that the sound is originating from -+ * @return originating entity -+ */ -+ public @NotNull Entity getOrigin() { -+ return origin; -+ } -+ -+ /** -+ * Sets the entity that the sound will originate from -+ * @param origin originating entity -+ */ -+ public void setOrigin(@NotNull Entity origin) { -+ Validate.notNull(origin, "origin cannot be null"); -+ if (!this.origin.getWorld().equals(origin.getWorld())) -+ throw new IllegalArgumentException("Entity must be in same world as originating location"); -+ this.origin = origin; -+ } -+ -+ @Override -+ public @org.jetbrains.annotations.NotNull World getWorld() { -+ return origin.getWorld(); -+ } -+} -diff --git a/src/main/java/gg/projecteden/parchment/event/sound/LocationCustomSoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/LocationCustomSoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..eed6098d16e051484129396c694b9cfbb8172fce ---- /dev/null -+++ b/src/main/java/gg/projecteden/parchment/event/sound/LocationCustomSoundEvent.java -@@ -0,0 +1,95 @@ -+package gg.projecteden.parchment.event.sound; -+ -+import gg.projecteden.parchment.HasLocation; -+import org.apache.commons.lang.Validate; -+import org.bukkit.Keyed; -+import org.bukkit.Location; -+import org.bukkit.NamespacedKey; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import static com.google.common.base.Preconditions.checkNotNull; -+ -+/** -+ * Called when a sound not available in {@link org.bukkit.Sound} is sent to a player from a {@link Location}. Cancelling this event will prevent the packet from sending. -+ */ -+public class LocationCustomSoundEvent extends SoundEvent implements Keyed, HasLocation { -+ private @NotNull Vector vector; -+ private @NotNull NamespacedKey key; -+ private @NotNull final World world; -+ -+ public LocationCustomSoundEvent(@Nullable HumanEntity receiver, @NotNull World world, @NotNull Vector vector, @NotNull NamespacedKey key, @NotNull SoundCategory category, float volume, float pitch) { -+ super(receiver, category, volume, pitch); -+ Validate.notNull(world, "world cannot be null"); -+ Validate.notNull(vector, "vector cannot be null"); -+ Validate.notNull(key, "key cannot be null"); -+ this.world = world; -+ this.vector = vector; -+ this.key = key; -+ } -+ -+ public LocationCustomSoundEvent(@Nullable HumanEntity receiver, @NotNull Location location, @NotNull NamespacedKey key, @NotNull SoundCategory category, float volume, float pitch) { -+ this(receiver, checkNotNull(location, "location").getWorld(), location.toVector(), key, category, volume, pitch); -+ } -+ -+ public LocationCustomSoundEvent(@NotNull HumanEntity receiver, @NotNull Vector vector, @NotNull NamespacedKey key, @NotNull SoundCategory category, float volume, float pitch) { -+ this(checkNotNull(receiver, "receiver"), receiver.getWorld(), vector, key, category, volume, pitch); -+ } -+ -+ public LocationCustomSoundEvent(@NotNull HumanEntity receiver, @NotNull NamespacedKey key, @NotNull SoundCategory category, float volume, float pitch) { -+ this(checkNotNull(receiver, "receiver"), receiver.getLocation().toVector(), key, category, volume, pitch); -+ } -+ -+ /** -+ * Gets the position in the world of the sound -+ * @return position in the world -+ */ -+ public @NotNull Vector getVector() { -+ return vector; -+ } -+ -+ /** -+ * Gets the resource pack key of the sound -+ * @return asset key -+ */ -+ public @NotNull NamespacedKey getKey() { -+ return key; -+ } -+ -+ @Override -+ public @NotNull World getWorld() { -+ return world; -+ } -+ -+ /** -+ * Gets the location of the sound being played -+ * @return copy of sound location -+ * @see #getVector() -+ * @see #setVector(Vector) -+ */ -+ public @NotNull Location getLocation() { -+ return new Location(world, vector.getX(), vector.getY(), vector.getZ()); -+ } -+ -+ /** -+ * Sets the position in the world of the sound -+ * @param vector position in the world -+ */ -+ public void setVector(@NotNull Vector vector) { -+ Validate.notNull(vector, "vector cannot be null"); -+ this.vector = vector; -+ } -+ -+ /** -+ * Sets the resource pack key of the sound -+ * @param key asset key -+ */ -+ public void setKey(@NotNull NamespacedKey key) { -+ Validate.notNull(key, "key cannot be null"); -+ this.key = key; -+ } -+} -diff --git a/src/main/java/gg/projecteden/parchment/event/sound/LocationNamedSoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/LocationNamedSoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0872f3850860fe7cca28aeabed6235cc2a805c94 ---- /dev/null -+++ b/src/main/java/gg/projecteden/parchment/event/sound/LocationNamedSoundEvent.java -@@ -0,0 +1,72 @@ -+package gg.projecteden.parchment.event.sound; -+ -+import gg.projecteden.parchment.HasLocation; -+import org.apache.commons.lang.Validate; -+import org.bukkit.Location; -+import org.bukkit.Sound; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import static com.google.common.base.Preconditions.checkNotNull; -+ -+/** -+ * Called when a sound available in {@link Sound} is sent to a player from a {@link Location}. Cancelling this event will prevent the packet from sending. -+ */ -+public class LocationNamedSoundEvent extends NamedSoundEvent implements HasLocation { -+ private @NotNull Vector vector; -+ private @NotNull final World world; -+ -+ public LocationNamedSoundEvent(@Nullable HumanEntity receiver, @NotNull World world, @NotNull Vector vector, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ super(receiver, sound, category, volume, pitch); -+ this.world = checkNotNull(world, "world"); -+ this.vector = checkNotNull(vector, "vector"); -+ } -+ -+ public LocationNamedSoundEvent(@Nullable HumanEntity receiver, @NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ this(receiver, checkNotNull(location, "location").getWorld(), location.toVector(), sound, category, volume, pitch); -+ } -+ -+ public LocationNamedSoundEvent(@NotNull HumanEntity receiver, @NotNull Vector vector, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ this(checkNotNull(receiver, "receiver"), receiver.getWorld(), vector, sound, category, volume, pitch); -+ } -+ -+ public LocationNamedSoundEvent(@NotNull HumanEntity receiver, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ this(checkNotNull(receiver, "receiver"), receiver.getLocation().toVector(), sound, category, volume, pitch); -+ } -+ -+ /** -+ * Gets the position in the world of the sound -+ * @return position in the world -+ */ -+ public @NotNull Vector getVector() { -+ return vector; -+ } -+ -+ @Override -+ public @NotNull World getWorld() { -+ return world; -+ } -+ -+ /** -+ * Gets the location of the sound being played -+ * @return copy of sound location -+ * @see #getVector() -+ * @see #setVector(Vector) -+ */ -+ public @NotNull Location getLocation() { -+ return new Location(world, vector.getX(), vector.getY(), vector.getZ()); -+ } -+ -+ /** -+ * Sets the position in the world of the sound -+ * @param vector position in the world -+ */ -+ public void setVector(@NotNull Vector vector) { -+ Validate.notNull(vector, "vector cannot be null"); -+ this.vector = vector; -+ } -+} -diff --git a/src/main/java/gg/projecteden/parchment/event/sound/NamedSoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/NamedSoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..9c2e257de3487a73d4f5b796177061d8fea4c0f7 ---- /dev/null -+++ b/src/main/java/gg/projecteden/parchment/event/sound/NamedSoundEvent.java -@@ -0,0 +1,38 @@ -+package gg.projecteden.parchment.event.sound; -+ -+import org.apache.commons.lang.Validate; -+import org.bukkit.Sound; -+import org.bukkit.SoundCategory; -+import org.bukkit.entity.HumanEntity; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+/** -+ * Called when a sound available in {@link Sound} is sent to a player. Cancelling this event will prevent the packet from sending. -+ */ -+public abstract class NamedSoundEvent extends SoundEvent { -+ private @NotNull Sound sound; -+ -+ public NamedSoundEvent(@Nullable HumanEntity receiver, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ super(receiver, category, volume, pitch); -+ Validate.notNull(sound, "sound cannot be null"); -+ this.sound = sound; -+ } -+ -+ /** -+ * Gets the sound being played -+ * @return sound to play -+ */ -+ public @NotNull Sound getSound() { -+ return sound; -+ } -+ -+ /** -+ * Sets the sound yo played -+ * @param sound sound to play -+ */ -+ public void setSound(@NotNull Sound sound) { -+ Validate.notNull(sound, "sound cannot be null"); -+ this.sound = sound; -+ } -+} diff --git a/src/main/java/gg/projecteden/parchment/event/sound/SoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/SoundEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..0506c9e461296aeb12da23b476b9b1c57702b7e1 +index 0000000000000000000000000000000000000000..427161356c432b5dc5d69a53801c1cd3540d7c38 --- /dev/null +++ b/src/main/java/gg/projecteden/parchment/event/sound/SoundEvent.java -@@ -0,0 +1,123 @@ +@@ -0,0 +1,380 @@ +package gg.projecteden.parchment.event.sound; + +import gg.projecteden.parchment.OptionalHumanEntity; -+import org.apache.commons.lang.Validate; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; ++import net.kyori.adventure.sound.Sound; ++import org.bukkit.Location; ++import org.bukkit.entity.Entity; +import org.bukkit.entity.HumanEntity; ++import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; ++import org.slf4j.Logger; ++ ++import java.util.ArrayList; ++import java.util.List; ++import java.util.Objects; ++import java.util.function.Function; + +/** -+ * Called when a sound is sent to a player. Cancelling this event will prevent the packet from sending. ++ * Called when a sound is sent to a player. ++ * Cancelling this event will prevent the packet from sending. + */ -+public abstract class SoundEvent extends Event implements Cancellable, OptionalHumanEntity { -+ private @Nullable final HumanEntity receiver; -+ private @NotNull SoundCategory category; -+ private float volume; -+ private float pitch; ++public final class SoundEvent extends Event implements Cancellable, OptionalHumanEntity { ++ private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(SoundEvent.class); + -+ public SoundEvent(@Nullable HumanEntity receiver, @NotNull SoundCategory category, float volume, float pitch) { -+ super(true); -+ Validate.notNull(category, "category cannot be null"); -+ this.receiver = receiver; -+ this.category = category; -+ this.volume = volume; -+ this.pitch = pitch; -+ } -+ -+ /** -+ * Gets the player that this sound will be sent to. May be null if the sound is being played to several players. -+ * @return player receiving the sound -+ */ -+ @Override -+ public @Nullable HumanEntity getPlayer() { -+ return receiver; -+ } -+ -+ /** -+ * Gets the category of sounds this will be played with. -+ * @return category of sounds -+ */ -+ public @NotNull SoundCategory getCategory() { -+ return category; -+ } -+ -+ /** -+ * Gets the volume of the sound to be played. Should be non-negative. -+ * @return sound volume -+ */ -+ public float getVolume() { -+ return volume; -+ } -+ -+ /** -+ * Gets the pitch of the sound to be played. Should be within the range [0,2]. -+ * @return sound pitch -+ */ -+ public float getPitch() { -+ return pitch; -+ } -+ -+ /** -+ * Sets the category of sounds this will be played with. -+ * @param category category of sounds -+ */ -+ public void setCategory(@NotNull SoundCategory category) { -+ Validate.notNull(category, "category cannot be null"); -+ this.category = category; -+ } -+ -+ /** -+ * Sets the volume of the sound to be played. Must be non-negative. -+ * @param volume sound volume -+ */ -+ public void setVolume(float volume) { -+ Validate.isTrue(volume >= 0, "volume should be non-negative"); -+ this.volume = volume; -+ } -+ -+ /** -+ * Sets the pitch of the sound to be played. Must be within the range [0,2]. -+ * @param pitch sound pitch -+ */ -+ public void setPitch(float pitch) { -+ Validate.isTrue(pitch >= 0 && pitch <= 2, "pitch should be within range [0,2]"); -+ this.pitch = pitch; -+ } -+ -+ // boilerplate ++ private static final org.bukkit.event.HandlerList handlers = new org.bukkit.event.HandlerList(); ++ public static final @NotNull Function DEFAULT_DISTANCE_FUNCTION = event -> event.volume() > 1.0F ? (double) (16.0F * event.volume()) : 16.0D; ++ public static final @NotNull Function> DEFAULT_RECIPIENTS_FUNCTION = new WrappedRecipientsFunction(event -> { ++ final double distance = event.calculateDistance(); ++ final Location loc = event.getEmitter().location(); ++ return loc.getWorld().getPlayers().stream() ++ .filter(player -> { ++ Location pl = player.getLocation(); ++ double x = loc.getX() - pl.getX(); ++ double y = loc.getY() - pl.getY(); ++ double z = loc.getZ() - pl.getZ(); ++ return x * x + y * y + z * z < distance * distance; ++ }) ++ .toList(); ++ }); + ++ private @Nullable HumanEntity except; ++ private @NotNull Function<@NotNull Sound, @NotNull Double> distanceFunction; ++ private @NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> recipientsFunction; // TODO replace with Player -> Nullable Sound function ? ++ private @NotNull Sound sound; ++ private @NotNull Emitter emitter; + private boolean cancelled; ++ private long seed; ++ private @Nullable Function<@NotNull Player, @Nullable Sound> soundOverrideFunction; ++ private @Nullable Function<@NotNull Player, @Nullable Emitter> emitterOverrideFunction; ++ ++ public SoundEvent(@Nullable HumanEntity except, @NotNull Sound sound, @NotNull Emitter emitter, long seed, @Nullable Function distanceFunction, @Nullable Function> recipientsFunction) { ++ super(true); ++ this.except = except; ++ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); ++ this.emitter = Objects.requireNonNull(emitter, "emitter cannot be null"); ++ this.seed = seed; ++ this.distanceFunction = Objects.requireNonNullElse(distanceFunction, DEFAULT_DISTANCE_FUNCTION); ++ this.recipientsFunction = wrapRecipientsFunction(Objects.requireNonNullElse(recipientsFunction, DEFAULT_RECIPIENTS_FUNCTION)); ++ } ++ ++ /** ++ * Gets the player that won't be receiving this sound. ++ * ++ * @return player excluded from receiving this sound ++ * @deprecated use {@link #getException()} for more clarity ++ */ ++ @Override ++ @Deprecated ++ public @Nullable HumanEntity getPlayer() { ++ return getException(); ++ } ++ ++ /** ++ * Gets the player that won't be receiving this sound. ++ * ++ * @return player excluded from receiving this sound ++ */ ++ public @Nullable HumanEntity getException() { ++ return except; ++ } ++ ++ /** ++ * Sets the player that won't be receiving this sound. ++ * ++ * @param except player excluded from receiving this sound ++ */ ++ public void setException(@Nullable HumanEntity except) { ++ this.except = except; ++ } ++ ++ /** ++ * Gets the sound that will be sent. ++ * ++ * @return sound that will be sent ++ */ ++ public @NotNull Sound getSound() { ++ return sound; ++ } ++ ++ /** ++ * Sets the sound that will be sent. ++ * ++ * @param sound sound that will be sent ++ */ ++ public void setSound(@NotNull Sound sound) { ++ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); ++ } ++ ++ /** ++ * Gets the emitter which determines how and where the sound will be played from. ++ * ++ * @return emitter which determines how and where the sound will be played from ++ */ ++ public @NotNull Emitter getEmitter() { ++ return emitter; ++ } ++ ++ /** ++ * Sets the emitter which determines how and where the sound will be played from. ++ * ++ * @param emitter emitter which determines how and where the sound will be played from ++ */ ++ public void setEmitter(@NotNull Emitter emitter) { ++ this.emitter = Objects.requireNonNull(emitter, "emitter cannot be null"); ++ } ++ ++ /** ++ * Gets the seed used to generate the sound. ++ * ++ * @return seed used to generate the sound ++ */ ++ public long getSeed() { ++ return seed; ++ } ++ ++ /** ++ * Sets the seed used to generate the sound. ++ * ++ * @param seed seed used to generate the sound ++ */ ++ public void setSeed(long seed) { ++ this.seed = seed; ++ } ++ ++ /** ++ * Calculates the distance of the sound. ++ *

++ * The distance value is dynamically calculated using a ++ * {@link Function Function<SoundEvent, Double>}. ++ * In vanilla Minecraft, the default function is {@link #DEFAULT_DISTANCE_FUNCTION} ++ * ({@code event -> event.getVolume() > 1.0F ? (double) (16.0F * event.getVolume()) : 16.0D}). ++ *

++ * This is used by the vanilla implementation of {@link #calculateRecipients()}, though custom ++ * implementations won't always use this method. ++ * ++ * @return calculated distance ++ * @see #getDistanceFunction() ++ * @see #setDistanceFunction(Function) ++ */ ++ public double calculateDistance() { ++ return distanceFunction.apply(sound); ++ } ++ ++ /** ++ * Gets the function that calculates the distance of the sound. ++ * ++ * @return distance function ++ * @see #calculateDistance() ++ * @see #setDistanceFunction(Function) ++ */ ++ public @NotNull Function<@NotNull Sound, @NotNull Double> getDistanceFunction() { ++ return distanceFunction; ++ } ++ ++ /** ++ * Sets the function that calculates the distance of the sound. ++ * ++ * @param distanceFunction distance function ++ * @see #calculateDistance() ++ * @see #getDistanceFunction() ++ */ ++ public void setDistanceFunction(@NotNull Function<@NotNull Sound, @NotNull Double> distanceFunction) { ++ this.distanceFunction = Objects.requireNonNull(distanceFunction, "distanceFunction cannot be null"); ++ } ++ ++ /** ++ * Determines which players will receive this sound packet. ++ * ++ * @return immutable list of players ++ * @see #getRecipientsFunction() ++ * @see #setRecipientsFunction(Function) ++ */ ++ public @NotNull List calculateRecipients() { ++ return recipientsFunction.apply(this); ++ } ++ ++ /** ++ * Gets the function that determines which players will receive the sound packet. ++ * ++ * @return recipients function ++ * @see #calculateRecipients() ++ * @see #setRecipientsFunction(Function) ++ */ ++ public @NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> getRecipientsFunction() { ++ return recipientsFunction; ++ } ++ ++ /** ++ * Sets the function that determines which players will receive the sound packet. ++ *

++ * This function does not need to query {@link #getException()} as this is done automatically. ++ * ++ * @param recipientsFunction recipients function ++ * @see #calculateRecipients() ++ * @see #getRecipientsFunction() ++ */ ++ public void setRecipientsFunction(@NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> recipientsFunction) { ++ this.recipientsFunction = wrapRecipientsFunction(Objects.requireNonNull(recipientsFunction, "recipientsFunction cannot be null")); ++ } ++ ++ /** ++ * Gets the function that overrides what {@link Sound} is sent to a {@link Player}. ++ * ++ * @return sound override function (or {@code null} if not overridden) ++ */ ++ public @Nullable Function<@NotNull Player, @Nullable Sound> getSoundOverrideFunction() { ++ return soundOverrideFunction; ++ } ++ ++ /** ++ * Sets the function that overrides what {@link Sound} is sent to a {@link Player}. ++ * ++ * @param soundOverrideFunction function which accepts a player and returns a sound ++ * (or {@code null} if the default sound should be used) ++ */ ++ public void setSoundOverrideFunction(@Nullable Function<@NotNull Player, @Nullable Sound> soundOverrideFunction) { ++ this.soundOverrideFunction = soundOverrideFunction; ++ } ++ ++ /** ++ * Calculates the sound that will be sent to a {@link Player}. ++ * ++ * @param player player to calculate the sound for ++ * @return sound that will be sent to the player ++ */ ++ public @NotNull Sound calculateSound(@NotNull Player player) { ++ if (soundOverrideFunction != null) { ++ try { ++ Sound override = soundOverrideFunction.apply(player); ++ if (override != null) { ++ return override; ++ } ++ } catch (Throwable e) { ++ LOGGER.error("Error while overriding sound for player " + player.getName(), e); ++ } ++ } ++ return sound; ++ } ++ ++ /** ++ * Gets the function that overrides what {@link Emitter} is used when playing this sound to a ++ * {@link Player}. ++ * ++ * @return emitter override function (or {@code null} if not overridden) ++ */ ++ public @Nullable Function<@NotNull Player, @Nullable Emitter> getEmitterOverrideFunction() { ++ return emitterOverrideFunction; ++ } ++ ++ /** ++ * Sets the function that overrides what {@link Emitter} is used when playing this sound to a ++ * {@link Player}. ++ * ++ * @param emitterOverrideFunction function which accepts a player and returns an emitter ++ * (or {@code null} if the default emitter should be used) ++ */ ++ public void setEmitterOverrideFunction(@Nullable Function<@NotNull Player, @Nullable Emitter> emitterOverrideFunction) { ++ this.emitterOverrideFunction = emitterOverrideFunction; ++ } ++ ++ /** ++ * Calculates the emitter that will be used when playing this sound to a {@link Player}. ++ * ++ * @param player player to calculate the emitter for ++ * @return emitter that will be used when playing the sound to the player ++ */ ++ public @NotNull Emitter calculateEmitter(@NotNull Player player) { ++ if (emitterOverrideFunction != null) { ++ try { ++ Emitter override = emitterOverrideFunction.apply(player); ++ if (override != null) { ++ return override; ++ } ++ } catch (Throwable e) { ++ LOGGER.error("Error while overriding emitter for player " + player.getName(), e); ++ } ++ } ++ return emitter; ++ } + + @Override + public boolean isCancelled() { @@ -392,22 +322,71 @@ index 0000000000000000000000000000000000000000..0506c9e461296aeb12da23b476b9b1c5 + this.cancelled = cancelled; + } + -+ /** -+ * Gets the world in which the sound is being played -+ * @return sound's world -+ */ + @NotNull -+ public abstract World getWorld(); -+ -+ private static final org.bukkit.event.HandlerList handlers = new org.bukkit.event.HandlerList(); ++ public static org.bukkit.event.HandlerList getHandlerList() { ++ return handlers; ++ } + + @Override + public @NotNull org.bukkit.event.HandlerList getHandlers() { + return handlers; + } + ++ private record WrappedRecipientsFunction(@NotNull Function> wrapped) implements Function> { ++ @Override ++ public List apply(SoundEvent event) { ++ List recipients = wrapped.apply(event); ++ HumanEntity except = event.getException(); ++ if (except != null) { ++ List filteredRecipients = new ArrayList<>(recipients.size()); ++ for (Player player : recipients) { ++ if (!player.getUniqueId().equals(except.getUniqueId())) ++ filteredRecipients.add(player); ++ } ++ return filteredRecipients; ++ } ++ return recipients; ++ } ++ } ++ + @NotNull -+ public static org.bukkit.event.HandlerList getHandlerList() { -+ return handlers; ++ private static Function> wrapRecipientsFunction(@NotNull Function> recipientsFunction) { ++ if (recipientsFunction instanceof WrappedRecipientsFunction) ++ return recipientsFunction; ++ else ++ return new WrappedRecipientsFunction(recipientsFunction); ++ } ++ ++ /** ++ * The class which determines where a sound will emit from. ++ */ ++ public sealed interface Emitter permits EntityEmitter, LocationEmitter { ++ /** ++ * Gets the location at which the sound will be played. ++ * ++ * @return sound's location ++ */ ++ @NotNull ++ Location location(); ++ } ++ ++ /** ++ * An emitter which plays a sound from an entity. ++ * ++ * @param entity the entity from which the sound will be played ++ */ ++ public record EntityEmitter(@NotNull Entity entity) implements Emitter { ++ @Override ++ public @NotNull Location location() { ++ return entity.getLocation(); ++ } ++ } ++ ++ /** ++ * An emitter which plays a sound from a location. ++ * ++ * @param location the location from which the sound will be played ++ */ ++ public record LocationEmitter(@NotNull Location location) implements Emitter { + } +} diff --git a/patches/api/0005-Expanded-Adventure-support.patch b/patches/api/0005-Expanded-Adventure-support.patch index 5751986..1d9e1a9 100644 --- a/patches/api/0005-Expanded-Adventure-support.patch +++ b/patches/api/0005-Expanded-Adventure-support.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Expanded Adventure support Adds support for Adventure in a few places where it was previously missing. diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java -index 4594701d77c5d0f744bece871b98d9f6f73eb5a7..136f87f6cd2f3a56cfa645084fd6446a20f2e88e 100644 +index f6eb30f53dad684f156102cf7147b2f00c82c71e..1b4e9840f0e829be533ad0bd1c918489642245c2 100644 --- a/src/main/java/org/bukkit/ChatColor.java +++ b/src/main/java/org/bukkit/ChatColor.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable; @@ -120,10 +120,10 @@ index 4594701d77c5d0f744bece871b98d9f6f73eb5a7..136f87f6cd2f3a56cfa645084fd6446a * Gets the char value associated with this color * diff --git a/src/main/java/org/bukkit/Color.java b/src/main/java/org/bukkit/Color.java -index deae003b7e9a96bbf1c0167d3e1d864e61b07f82..53afcd97fc34bceff741ee118f63226781f9c895 100644 +index d2f8f5a8e49f60422b6a41e51248a6710251d61b..40b09a861ba365b126c2b28bb7f18c8fb8b3e5b5 100644 --- a/src/main/java/org/bukkit/Color.java +++ b/src/main/java/org/bukkit/Color.java -@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; +@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull; * but subject to change. */ @SerializableAs("Color") @@ -132,7 +132,7 @@ index deae003b7e9a96bbf1c0167d3e1d864e61b07f82..53afcd97fc34bceff741ee118f632267 private static final int BIT_MASK = 0xff; /** -@@ -242,6 +242,13 @@ public final class Color implements ConfigurationSerializable { +@@ -244,6 +244,13 @@ public final class Color implements ConfigurationSerializable { return getRed() << 16 | getGreen() << 8 | getBlue() << 0; } diff --git a/patches/api/0008-Expose-MCUtil-Executors.patch b/patches/api/0008-Expose-MCUtil-Executors.patch index 17bcbeb..dceba84 100644 --- a/patches/api/0008-Expose-MCUtil-Executors.patch +++ b/patches/api/0008-Expose-MCUtil-Executors.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose MCUtil Executors diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 79b26045a68ebb9b01e5bd06abbccaaef5489777..da7d4eb2beea848e60d8c8cfe2a5abf0d6761950 100644 +index 30b49aed62fa67276e8964922ea3f84458d854bb..c78ca045a0a7fa651a34f76c802bb82cd6ac4d13 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2055,4 +2055,20 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2065,4 +2065,20 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull org.bukkit.potion.PotionBrewer getPotionBrewer(); // Paper end diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index 155a679..01455a4 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index 0282e3b75470e1a68ea1fc228082483514ba432e..9c860b39f1131920ea747783423a736b8ca2c915 100644 +index 68b8f275f9c9e77a949ca29749a05b469bcdb910..82d6922ca22eee74de2140789787e6e5da51378c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,8 +9,8 @@ plugins { @@ -19,7 +19,7 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9c860b39f1131920ea747783423a736b // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -60,7 +60,7 @@ tasks.jar { +@@ -64,7 +64,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -28,7 +28,7 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9c860b39f1131920ea747783423a736b "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -77,7 +77,27 @@ tasks.jar { +@@ -81,7 +81,27 @@ tasks.jar { publishing { publications.create("maven") { @@ -57,7 +57,7 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9c860b39f1131920ea747783423a736b } } -@@ -148,7 +168,7 @@ fun TaskContainer.registerRunTask( +@@ -152,7 +172,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -67,7 +67,7 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9c860b39f1131920ea747783423a736b standardInput = System.`in` workingDir = rootProject.layout.projectDirectory diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 218f5bafeed8551b55b91c7fccaf6935c8b631ca..52126870f1fc15a9ddce4452673b236ea692860f 100644 +index 7b1843e16745ca8db2244e17490d291401f22679..c340575e9c2a114f2165b74feb4481975821811c 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -73,7 +73,7 @@ public class Metrics { @@ -104,10 +104,10 @@ index bf42969859545a8a520923ef1836ffa4a5cc24a0..2532e265c5dade55f71c34fcab6d1e74 org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion()); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index da15a224b8b974e78b9d8d5f514229b3b2a5a63e..f2b5e78b3fe68c38e755b9b4a8f96077ac6800f2 100644 +index 32dc0cd20a4dd8fc02be1f7ba3d727db826dbe5d..d48ac4df6f9cde9ccdc068010e977206dd838eaf 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1696,7 +1696,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop DISTANCE_FUNCTION = sound -> { ++ Optional 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 3f25a9b1a74cfa0c9a4d0379ecda109d99f33db3..b954cda43afbfd367f7f8f436dca65f900706ccb 100644 +--- a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java ++++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +@@ -302,6 +302,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 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 98209532ad3e692d7e459640123f78bbd9a65889..53f5e22370f3bc0d29cc38641d67e869305ced86 100644 +index 0dc7a827aeacc7fae53b1f975f45883da7db6a0c..782be663520c27fccb58484ec56cc94def38f136 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 { +@@ -1540,12 +1540,40 @@ 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 + 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 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 + 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 a6edf5117d4ae03d8294e7bb74dd2d77048895a5..0f29fd8768d4443211e85c96f624c12d60f488da 100644 +index c8057f98e16ba6e19640e0b250e5201e0f4f57db..f2048fe46e0231e877d4e61f30387406fef82d51 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 { +@@ -2221,7 +2221,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)); -+ 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 +- 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 624946f48f0811c94d05174f28d0b1fc6d5e6a00..ebc22dc4729146f9e28830a64204daf0084018a3 100644 +index 20cdfdb3b9351f74e89bc45b3ab972384165659a..aaef762c95584103937955413629aa11f7cf2bd0 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 { +@@ -977,7 +977,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 + 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 2483d7df7f1bf94344afd38b37602c645a4a2dff..ef8038587117829c84a237a52498496cd39ab91a 100644 +index cd9cbfa5ef94994b3f7f2ecdde843620e7e6c071..bc6bdc8752718777ac698cfda2a0e7f35fcf9896 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 { +@@ -1898,7 +1898,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 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 +- ((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 f50abfd058e3adf1cf8c0f4468a60bc04e8541e7..2ff60e8fa65626a9805597776b9163fd40e6807d 100644 +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 -@@ -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 { +@@ -526,7 +526,7 @@ public class Raid { + float f = 13.0F; + boolean flag = true; + Collection 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)); -+ entityplayer.playNotifySound(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, 64.0F, 1.0F); // Parchment +- 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 ceacb62aef0dd0f73f1542a1898ceb62c3f4c367..70d445429fec455f8188341ffd401e83f6bdab1c 100644 +index 1d8ec0f85ec42f2dcd9405df83b526ae1c59de6f..1547cd54b805e46ebcf8d7a910533f29537c2c55 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 { +@@ -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; +@@ -1919,4 +1918,52 @@ public class CraftEventFactory { return event.callEvent(); } // Paper end + + // Parchment start -+ private static net.minecraft.network.protocol.Packet 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); ++ private static net.minecraft.network.protocol.@org.jetbrains.annotations.NotNull Packet 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 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, java.util.function.Consumer> soundPlayer) { ++ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event) { + 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 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)); ++ if (!event.callEvent()) ++ return; ++ net.minecraft.server.MCUtil.asyncExecutor.execute(() -> { ++ 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 } diff --git a/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch b/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch index 0832f15..2f8c488 100644 --- a/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch +++ b/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add origin location to EntityDamageByBlockEvent diff --git a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java -index f5a18fb39eb69b2a9842d3f96aa1cd6a8dff6d9b..456d93305f524da6142bad320edb817b27c6c1e6 100644 +index 968c915cc494bb3c57169b7b3640002c3a4a8810..0c2b2cb4be57b11d748d13a0ec24b7470619267f 100644 --- a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java +++ b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java -@@ -9,12 +9,20 @@ import net.minecraft.network.chat.TranslatableComponent; +@@ -7,12 +7,20 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.world.entity.LivingEntity; public class BadRespawnPointDamage extends DamageSource { @@ -28,9 +28,9 @@ index f5a18fb39eb69b2a9842d3f96aa1cd6a8dff6d9b..456d93305f524da6142bad320edb817b + @Override public Component getLocalizedDeathMessage(LivingEntity entity) { - Component component = ComponentUtils.wrapInSquareBrackets(new TranslatableComponent("death.attack.badRespawnPoint.link")).withStyle((style) -> { + Component component = ComponentUtils.wrapInSquareBrackets(Component.translatable("death.attack.badRespawnPoint.link")).withStyle((style) -> { diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac704151682578718 100644 +index 67bce77093dcc126098731047447da2031e3388d..051cf78fe9f7700e1f639c804f35903c8079eae9 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java @@ -77,6 +77,18 @@ public class DamageSource { @@ -52,7 +52,7 @@ index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac7041516 public static DamageSource sting(LivingEntity attacker) { return new EntityDamageSource("sting", attacker); -@@ -127,17 +139,24 @@ public class DamageSource { +@@ -127,7 +139,7 @@ public class DamageSource { } public static DamageSource explosion(@Nullable Explosion explosion) { @@ -61,7 +61,8 @@ index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac7041516 } public static DamageSource explosion(@Nullable LivingEntity attacker) { - return attacker != null ? (new EntityDamageSource("explosion.player", attacker)).setScalesWithDifficulty().setExplosion() : (new DamageSource("explosion")).setScalesWithDifficulty().setExplosion(); +@@ -138,10 +150,17 @@ public class DamageSource { + return (new EntityDamageSource("sonic_boom", attacker)).bypassArmor().bypassEnchantments().setMagic(); } + @Deprecated // Parchment @@ -79,10 +80,10 @@ index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac7041516 return "DamageSource (" + this.msgId + ")"; } diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -index 8c4db2f0e5158872879da52a96bc592145e52e13..2b25f719205bccd697e8b57e942005d0524728b1 100644 +index 219877901fb5fc6401646253d6e5d7bd8416ffe1..caffd9b78d370019e98c9049a121c7d3734372e6 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -99,7 +99,7 @@ public class EnderDragon extends Mob implements Enemy { +@@ -98,7 +98,7 @@ public class EnderDragon extends Mob implements Enemy { private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -91,7 +92,7 @@ index 8c4db2f0e5158872879da52a96bc592145e52e13..2b25f719205bccd697e8b57e942005d0 // Paper start - add var for save custom podium @Nullable private BlockPos podium; -@@ -107,6 +107,7 @@ public class EnderDragon extends Mob implements Enemy { +@@ -106,6 +106,7 @@ public class EnderDragon extends Mob implements Enemy { public EnderDragon(EntityType entitytypes, Level world) { super(EntityType.ENDER_DRAGON, world); @@ -100,10 +101,10 @@ index 8c4db2f0e5158872879da52a96bc592145e52e13..2b25f719205bccd697e8b57e942005d0 this.setHealth(this.getMaxHealth()); this.noPhysics = true; diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 29f6c10e2c2626a9726d295acf12efea2b463cd3..370bde9e458a11c504a52356524fd289569612f1 100644 +index 01477e7240f9e33d08d416a7d40ee10f3e5d4abf..e8e1501f31b27d2e4448475db46f98304874575f 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -471,6 +471,13 @@ public class Explosion { +@@ -474,6 +474,13 @@ public class Explosion { return this.toBlow; } @@ -118,7 +119,7 @@ index 29f6c10e2c2626a9726d295acf12efea2b463cd3..370bde9e458a11c504a52356524fd289 NONE, BREAK, DESTROY; diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java -index 20c0030d566012146021613325c6a979f392740e..a0a052095815ed63f06837155b48b0d84f404240 100644 +index 654a859a37bf991c7a7fa8a44a3d20f8feb223db..52e6c9ea22273759ea9a827125bf561a62272ad9 100644 --- a/src/main/java/net/minecraft/world/level/block/BedBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java @@ -145,7 +145,10 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock @@ -134,7 +135,7 @@ index 20c0030d566012146021613325c6a979f392740e..a0a052095815ed63f06837155b48b0d8 } } diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java -index 7d33dae2617991bce244ad906df7053c22e3f515..797a583f0e3516b4a1bfec4c122eff438d174776 100644 +index 6be6adf73dc48ebbac22fe2a9be635f675f18cb1..e814c791137da2a10f4d4dd65f201fc220399975 100644 --- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java @@ -148,7 +148,10 @@ public class RespawnAnchorBlock extends Block { @@ -150,10 +151,10 @@ index 7d33dae2617991bce244ad906df7053c22e3f515..797a583f0e3516b4a1bfec4c122eff43 public static boolean canSetSpawn(Level world) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 70d445429fec455f8188341ffd401e83f6bdab1c..7df4e2bab4d0773d8246011368c8e1c82c8e49d4 100644 +index 1547cd54b805e46ebcf8d7a910533f29537c2c55..de6ec4c6d59d1b9fa203b0d373452e466a89e1ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -969,7 +969,7 @@ public class CraftEventFactory { +@@ -968,7 +968,7 @@ public class CraftEventFactory { CraftEventFactory.entityDamage = null; EntityDamageEvent event; if (damager == null) { @@ -162,7 +163,7 @@ index 70d445429fec455f8188341ffd401e83f6bdab1c..7df4e2bab4d0773d8246011368c8e1c8 } else if (entity instanceof EnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) { event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions); } else { -@@ -1007,7 +1007,7 @@ public class CraftEventFactory { +@@ -1008,7 +1008,7 @@ public class CraftEventFactory { return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API } else if (source == DamageSource.OUT_OF_WORLD) { @@ -171,7 +172,7 @@ index 70d445429fec455f8188341ffd401e83f6bdab1c..7df4e2bab4d0773d8246011368c8e1c8 event.setCancelled(cancelled); CraftEventFactory.callEvent(event); if (!event.isCancelled()) { -@@ -1017,7 +1017,7 @@ public class CraftEventFactory { +@@ -1018,7 +1018,7 @@ public class CraftEventFactory { } return event; } else if (source == DamageSource.LAVA) { diff --git a/patches/server/0007-Expose-EntityType-Ordinals.patch b/patches/server/0007-Expose-EntityType-Ordinals.patch index 6697d71..feb69fe 100644 --- a/patches/server/0007-Expose-EntityType-Ordinals.patch +++ b/patches/server/0007-Expose-EntityType-Ordinals.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose EntityType Ordinals diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 79abd84696ef099f6b12ddeaa6e398f18c53316a..13e277c9ff27a52fbf7041c36d7c5ff6d0028cfc 100644 +index ac0f0a4da4282c13f6e1f37710cb615d66b8ef2c..aa98cea349a3929cbb29fa01962ae98d9136cda7 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -150,6 +150,8 @@ import org.slf4j.Logger; +@@ -154,6 +154,8 @@ import org.slf4j.Logger; public class EntityType implements EntityTypeTest { @@ -17,7 +17,7 @@ index 79abd84696ef099f6b12ddeaa6e398f18c53316a..13e277c9ff27a52fbf7041c36d7c5ff6 private static final Logger LOGGER = LogUtils.getLogger(); public static final String ENTITY_TAG = "EntityTag"; private final Holder.Reference> builtInRegistryHolder; -@@ -285,9 +287,31 @@ public class EntityType implements EntityTypeTest { +@@ -294,9 +296,31 @@ public class EntityType implements EntityTypeTest { private final EntityDimensions dimensions; private static EntityType register(String id, EntityType.Builder type) { // CraftBukkit - decompile error @@ -51,7 +51,7 @@ index 79abd84696ef099f6b12ddeaa6e398f18c53316a..13e277c9ff27a52fbf7041c36d7c5ff6 return Registry.ENTITY_TYPE.getKey(type); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 0507e40c97567fc379ebe4d0b001af16922ddb3e..5f86de03f280b2e3d9e32e11a8df5761ea6591ee 100644 +index ee4d1e3f0be4ac94bb03263425b2acfa97a85c0d..840017182f0c75af07bd461d59fc340b3c304b8a 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -653,6 +653,18 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0008-Add-Player-setGameProfile.patch b/patches/server/0008-Add-Player-setGameProfile.patch index e75c74b..128cdca 100644 --- a/patches/server/0008-Add-Player-setGameProfile.patch +++ b/patches/server/0008-Add-Player-setGameProfile.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Add Player#setGameProfile 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 ef8038587117829c84a237a52498496cd39ab91a..f087f8b61d50541fbf527331f4d8e625aa0f8e0d 100644 +index bc6bdc8752718777ac698cfda2a0e7f35fcf9896..05584d344c9f7d6d89bb8fbdfa254c1dca91b590 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1468,6 +1468,12 @@ public abstract class Player extends LivingEntity { +@@ -1511,6 +1511,12 @@ public abstract class Player extends LivingEntity { return this.gameProfile; } -+ // Parchment start ++ // Parchment start | TODO: rename to match getter + public void setProfile(GameProfile gameProfile) { + this.gameProfile = gameProfile; + } + // Parchment end + - public Inventory getInventory() { - return this.inventory; - } + @Nullable + public ProfilePublicKey getProfilePublicKey() { + return this.profilePublicKey; diff --git a/patches/server/0009-Expose-MCUtil-Executors.patch b/patches/server/0009-Expose-MCUtil-Executors.patch index 83885ec..9502756 100644 --- a/patches/server/0009-Expose-MCUtil-Executors.patch +++ b/patches/server/0009-Expose-MCUtil-Executors.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose MCUtil Executors diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 83f75d9c4ad146ba0a0ef28d0e49a1deb6db6a44..cfda86ba398a853427b4a6a14e3fdf2723f07a83 100644 +index f4847a8671bd21f78af598faacea5c763669ddbc..97e60454716eacdfa4420efff2596b7f99d2bfd6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2886,4 +2886,16 @@ public final class CraftServer implements Server { +@@ -2869,4 +2869,16 @@ public final class CraftServer implements Server { } // Paper end diff --git a/patches/server/0011-Add-BlockDropResourcesEvent.patch b/patches/server/0011-Add-BlockDropResourcesEvent.patch index 9a18801..5266ba2 100644 --- a/patches/server/0011-Add-BlockDropResourcesEvent.patch +++ b/patches/server/0011-Add-BlockDropResourcesEvent.patch @@ -8,10 +8,10 @@ to easily get the items being dropped by any block instead of only blocks broken by players. diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index a80f4dc0a642c744223a155232291ace6e007636..f76849d67d71bf5bed1b9006adfee1c1b90b05d6 100644 +index 224ce424b9a22548212ac157ec273c6dd80d6cfb..f33a8f7e46f9d88137de509e22d73edea3804cbe 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -306,7 +306,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -308,7 +308,7 @@ public class Block extends BlockBehaviour implements ItemLike { ServerLevel worldserver = lootContext.getLevel(); BlockPos blockposition = new BlockPos((Vec3) lootContext.getParameter(LootContextParams.ORIGIN)); @@ -19,8 +19,8 @@ index a80f4dc0a642c744223a155232291ace6e007636..f76849d67d71bf5bed1b9006adfee1c1 + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(worldserver, blockposition, state.getDrops(lootContext)).forEach((itemstack) -> { // Parchment Block.popResource(worldserver, blockposition, itemstack); }); - state.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY); -@@ -314,7 +314,7 @@ public class Block extends BlockBehaviour implements ItemLike { + state.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, true); +@@ -316,7 +316,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, Level world, BlockPos pos) { if (world instanceof ServerLevel) { @@ -28,8 +28,8 @@ index a80f4dc0a642c744223a155232291ace6e007636..f76849d67d71bf5bed1b9006adfee1c1 + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, (BlockEntity) null)).forEach((itemstack) -> { // Parchment Block.popResource(world, pos, itemstack); }); - state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); -@@ -324,7 +324,7 @@ public class Block extends BlockBehaviour implements ItemLike { + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true); +@@ -326,7 +326,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity) { if (world instanceof ServerLevel) { @@ -37,8 +37,8 @@ index a80f4dc0a642c744223a155232291ace6e007636..f76849d67d71bf5bed1b9006adfee1c1 + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, blockEntity)).forEach((itemstack) -> { // Parchment Block.popResource((ServerLevel) world, pos, itemstack); }); - state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); -@@ -351,7 +351,7 @@ public class Block extends BlockBehaviour implements ItemLike { + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true); +@@ -353,7 +353,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack stack) { if (world instanceof ServerLevel) { @@ -46,14 +46,14 @@ index a80f4dc0a642c744223a155232291ace6e007636..f76849d67d71bf5bed1b9006adfee1c1 + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, stack)).forEach((itemstack1) -> { // Parchment Block.popResource(world, pos, itemstack1); }); - state.spawnAfterBreak((ServerLevel) world, pos, stack); + state.spawnAfterBreak((ServerLevel) world, pos, stack, true); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 7df4e2bab4d0773d8246011368c8e1c82c8e49d4..7f2cb8bec323fc0fc5188f2cd5efad73cf85301c 100644 +index de6ec4c6d59d1b9fa203b0d373452e466a89e1ec..6ff4c2cc4e49796e947dc70db1eff475e0eeaa3b 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1989,5 +1989,19 @@ public class CraftEventFactory { - final double posZ = pos.getZ(); - playSoundEvent(event, packet -> playerList.broadcast(player, posX, posY, posZ, radius, world, packet)); +@@ -1965,5 +1965,19 @@ public class CraftEventFactory { + } + }); } + + public static List callBlockDropResourcesEvent(LevelAccessor world, BlockPos pos, List items) { diff --git a/patches/server/0012-Add-Furnace-Recipe-API.patch b/patches/server/0012-Add-Furnace-Recipe-API.patch index ad1f2ee..0167924 100644 --- a/patches/server/0012-Add-Furnace-Recipe-API.patch +++ b/patches/server/0012-Add-Furnace-Recipe-API.patch @@ -215,10 +215,10 @@ index 0000000000000000000000000000000000000000..e7114e456f818d7bdd4081620f4b9b93 + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 43244a479a112786539a905a22cb12e3cf55b2dd..72b0a17a52169c0bd6b985e82278fffa73340298 100644 +index 25e56be9055c5c432e1180d45341f4e9d9fcb7ca..4e8dbefb953a8ca09dda1e195591c10ebd9b0243 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2322,4 +2322,11 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2321,4 +2321,11 @@ public class CraftWorld extends CraftRegionAccessor implements World { return this.adventure$pointers; } // Paper end diff --git a/patches/server/0013-Disable-sleep-status-announcements.patch b/patches/server/0013-Disable-sleep-status-announcements.patch index 1120859..88e02b5 100644 --- a/patches/server/0013-Disable-sleep-status-announcements.patch +++ b/patches/server/0013-Disable-sleep-status-announcements.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable sleep status announcements diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 53f5e22370f3bc0d29cc38641d67e869305ced86..e4aaffe7ceecb0cf77172e2d96cfe50c8a708c37 100644 +index 782be663520c27fccb58484ec56cc94def38f136..e33d731d4689963fa9c5b2feef24a6b7b202988b 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -898,7 +898,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -918,7 +918,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } private void announceSleepStatus() { @@ -16,4 +16,4 @@ index 53f5e22370f3bc0d29cc38641d67e869305ced86..e4aaffe7ceecb0cf77172e2d96cfe50c + if (false && this.canSleepThroughNights()) { if (!this.getServer().isSingleplayer() || this.getServer().isPublished()) { int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); - TranslatableComponent chatmessage; + MutableComponent ichatmutablecomponent;