From 39ffbb788fd18d306de27f594dc69ddc26839281 Mon Sep 17 00:00:00 2001 From: Encode42 Date: Fri, 10 Jan 2025 02:01:54 -0800 Subject: [PATCH] Config to allow Note Block sounds when blocked Allows for Note Blocks to ignore whether or not there's air above them to play. Normally, the sounds will only play when the block directly above is air. With this patch enabled, players can place any block above the Note Block and it will still work. --- ...allow-Note-Block-sounds-when-blocked.patch | 44 ------------------- .../world/level/block/NoteBlock.java.patch | 11 +++++ .../purpurmc/purpur/PurpurWorldConfig.java | 3 +- 3 files changed, 13 insertions(+), 45 deletions(-) delete mode 100644 patches/server/0117-Config-to-allow-Note-Block-sounds-when-blocked.patch create mode 100644 purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch diff --git a/patches/server/0117-Config-to-allow-Note-Block-sounds-when-blocked.patch b/patches/server/0117-Config-to-allow-Note-Block-sounds-when-blocked.patch deleted file mode 100644 index cc1a46839..000000000 --- a/patches/server/0117-Config-to-allow-Note-Block-sounds-when-blocked.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Encode42 -Date: Fri, 8 Jan 2021 16:07:32 -0500 -Subject: [PATCH] Config to allow Note Block sounds when blocked - -Allows for Note Blocks to ignore whether or not there's air above them to play. - -Normally, the sounds will only play when the block directly above is air. -With this patch enabled, players can place any block above the Note Block and it will still work. - -diff --git a/net/minecraft/world/level/block/NoteBlock.java b/net/minecraft/world/level/block/NoteBlock.java -index 6582db84c5307257f16c321453491cf24e40c9c7..f9015d4e478efeec8a796b7a897638f76064db20 100644 ---- a/net/minecraft/world/level/block/NoteBlock.java -+++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -97,7 +97,7 @@ public class NoteBlock extends Block { - } - - private void playNote(@Nullable Entity entity, BlockState state, Level world, BlockPos pos) { -- if (((NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT)).worksAboveNoteBlock() || world.getBlockState(pos.above()).isAir()) { -+ if (world.purpurConfig.noteBlockIgnoreAbove || ((NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT)).worksAboveNoteBlock() || world.getBlockState(pos.above()).isAir()) { // Purpur - // CraftBukkit start - // org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, pos, state.getValue(NoteBlock.INSTRUMENT), state.getValue(NoteBlock.NOTE)); - // if (event.isCancelled()) { -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 4f31d65962618a29b0a52ec7c51fba2267d63a05..a71a380f20dad2f43183d128e7a487420248a671 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -124,6 +124,7 @@ public class PurpurWorldConfig { - public boolean entitiesPickUpLootBypassMobGriefing = false; - public boolean fireballsBypassMobGriefing = false; - public boolean projectilesBypassMobGriefing = false; -+ public boolean noteBlockIgnoreAbove = false; - private void miscGameplayMechanicsSettings() { - useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending); - boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand); -@@ -138,7 +139,7 @@ public class PurpurWorldConfig { - entitiesPickUpLootBypassMobGriefing = getBoolean("gameplay-mechanics.entities-pick-up-loot-bypass-mob-griefing", entitiesPickUpLootBypassMobGriefing); - fireballsBypassMobGriefing = getBoolean("gameplay-mechanics.fireballs-bypass-mob-griefing", fireballsBypassMobGriefing); - projectilesBypassMobGriefing = getBoolean("gameplay-mechanics.projectiles-bypass-mob-griefing", projectilesBypassMobGriefing); -- -+ noteBlockIgnoreAbove = getBoolean("gameplay-mechanics.note-block-ignore-above", noteBlockIgnoreAbove); - } - - public int daytimeTicks = 12000; diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch new file mode 100644 index 000000000..aac0b0985 --- /dev/null +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/NoteBlock.java ++++ b/net/minecraft/world/level/block/NoteBlock.java +@@ -107,7 +_,7 @@ + } + + private void playNote(@Nullable Entity entity, BlockState state, Level level, BlockPos pos) { +- if (state.getValue(INSTRUMENT).worksAboveNoteBlock() || level.getBlockState(pos.above()).isAir()) { ++ if (level.purpurConfig.noteBlockIgnoreAbove || state.getValue(INSTRUMENT).worksAboveNoteBlock() || level.getBlockState(pos.above()).isAir()) { // Purpur - Config to allow Note Block sounds when blocked + // CraftBukkit start + // org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, pos, state.getValue(NoteBlock.INSTRUMENT), state.getValue(NoteBlock.NOTE)); + // if (event.isCancelled()) { diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 7755c7515..e921ed903 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -116,6 +116,7 @@ public class PurpurWorldConfig { public boolean entitiesPickUpLootBypassMobGriefing = false; public boolean fireballsBypassMobGriefing = false; public boolean projectilesBypassMobGriefing = false; + public boolean noteBlockIgnoreAbove = false; private void miscGameplayMechanicsSettings() { useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending); boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand); @@ -130,7 +131,7 @@ public class PurpurWorldConfig { entitiesPickUpLootBypassMobGriefing = getBoolean("gameplay-mechanics.entities-pick-up-loot-bypass-mob-griefing", entitiesPickUpLootBypassMobGriefing); fireballsBypassMobGriefing = getBoolean("gameplay-mechanics.fireballs-bypass-mob-griefing", fireballsBypassMobGriefing); projectilesBypassMobGriefing = getBoolean("gameplay-mechanics.projectiles-bypass-mob-griefing", projectilesBypassMobGriefing); - + noteBlockIgnoreAbove = getBoolean("gameplay-mechanics.note-block-ignore-above", noteBlockIgnoreAbove); } public int daytimeTicks = 12000;