9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-19 15:09:27 +00:00

Remove unnecessary note block event patch because it is now merged into Paper

This commit is contained in:
MrPowerGamerBR
2022-02-04 17:22:15 -03:00
parent 27c9f72ec0
commit ca6e855978
7 changed files with 18 additions and 166 deletions

View File

@@ -4,7 +4,7 @@ plugins {
java java
`maven-publish` `maven-publish`
id("com.github.johnrengelman.shadow") version "7.1.0" apply false id("com.github.johnrengelman.shadow") version "7.1.0" apply false
id("io.papermc.paperweight.patcher") version "1.3.1" id("io.papermc.paperweight.patcher") version "1.3.4"
} }
repositories { repositories {
@@ -70,8 +70,8 @@ paperweight {
// Everything below here is optional if you don't care about publishing API or dev bundles to your repository // Everything below here is optional if you don't care about publishing API or dev bundles to your repository
// //
/* tasks.generateDevelopmentBundle { tasks.generateDevelopmentBundle {
apiCoordinates.set("com.example.paperfork:sparklypaper-api") apiCoordinates.set("net.sparklypower.sparklypaper:sparklypaper-api")
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi") mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
libraryRepositories.set( libraryRepositories.set(
listOf( listOf(
@@ -79,7 +79,7 @@ paperweight {
"https://libraries.minecraft.net/", "https://libraries.minecraft.net/",
"https://papermc.io/repo/repository/maven-public/", "https://papermc.io/repo/repository/maven-public/",
"https://maven.quiltmc.org/repository/release/", "https://maven.quiltmc.org/repository/release/",
// "https://my.repo/", // This should be a repo hosting your API (in this example, 'com.example.paperfork:forktest-api') "https://repo.perfectdreams.net/", // This should be a repo hosting your API (in this example, 'com.example.paperfork:forktest-api')
) )
) )
} }
@@ -90,8 +90,8 @@ allprojects {
publishing { publishing {
repositories { repositories {
maven { maven {
name = "myRepoSnapshots" name = "PerfectDreams"
url = uri("https://my.repo/") url = uri("https://repo.perfectdreams.net/")
// See Gradle docs for how to provide credentials to PasswordCredentials // See Gradle docs for how to provide credentials to PasswordCredentials
// https://docs.gradle.org/current/samples/sample_publishing_credentials.html // https://docs.gradle.org/current/samples/sample_publishing_credentials.html
credentials(PasswordCredentials::class) credentials(PasswordCredentials::class)
@@ -110,4 +110,4 @@ publishing {
} }
} }
} }
} */ }

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kieran Wallbanks <kieran.wallbanks@gmail.com>
Date: Mon, 21 Jun 2021 12:33:45 +0100
Subject: [PATCH] Fix NotePlayEvent
diff --git a/src/main/java/org/bukkit/event/block/NotePlayEvent.java b/src/main/java/org/bukkit/event/block/NotePlayEvent.java
index a3887067d1b65fb100ac1407a43c455f5d215510..676b31f6f38d4e85cd4bd16ccf42cbc39a5d8423 100644
--- a/src/main/java/org/bukkit/event/block/NotePlayEvent.java
+++ b/src/main/java/org/bukkit/event/block/NotePlayEvent.java
@@ -58,9 +58,7 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
* Overrides the {@link Instrument} to be used.
*
* @param instrument the Instrument. Has no effect if null.
- * @deprecated no effect on newer Minecraft versions
*/
- @Deprecated
public void setInstrument(@NotNull Instrument instrument) {
if (instrument != null) {
this.instrument = instrument;
@@ -71,9 +69,7 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
* Overrides the {@link Note} to be played.
*
* @param note the Note. Has no effect if null.
- * @deprecated no effect on newer Minecraft versions
*/
- @Deprecated
public void setNote(@NotNull Note note) {
if (note != null) {
this.note = note;

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] new fork who dis - Rebrand to SparklyPaper
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index cd74406039704e5a880f00b9b60bb7b1dedc5398..c4dfc34277e59143d346725c9ef2bfbcee59bc06 100644 index 028f6a1795ceb99d1760c73b0980238677b4b8bc..0216a5f72b5f3dec6cbebad9f400ac4211bc2c91 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -18,8 +18,12 @@ repositories { @@ -18,8 +18,12 @@ repositories {
@@ -23,7 +23,7 @@ index cd74406039704e5a880f00b9b60bb7b1dedc5398..c4dfc34277e59143d346725c9ef2bfbc
// Paper start // Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0") implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -67,7 +71,7 @@ tasks.jar { @@ -68,7 +72,7 @@ tasks.jar {
attributes( attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main", "Main-Class" to "org.bukkit.craftbukkit.Main",
"Implementation-Title" to "CraftBukkit", "Implementation-Title" to "CraftBukkit",
@@ -32,7 +32,7 @@ index cd74406039704e5a880f00b9b60bb7b1dedc5398..c4dfc34277e59143d346725c9ef2bfbc
"Implementation-Vendor" to date, // Paper "Implementation-Vendor" to date, // Paper
"Specification-Title" to "Bukkit", "Specification-Title" to "Bukkit",
"Specification-Version" to project.version, "Specification-Version" to project.version,
@@ -158,7 +162,7 @@ fun TaskContainer.registerRunTask( @@ -156,7 +160,7 @@ fun TaskContainer.registerRunTask(
name: String, name: String,
block: JavaExec.() -> Unit block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) { ): TaskProvider<JavaExec> = register<JavaExec>(name) {
@@ -42,10 +42,10 @@ index cd74406039704e5a880f00b9b60bb7b1dedc5398..c4dfc34277e59143d346725c9ef2bfbc
standardInput = System.`in` standardInput = System.`in`
workingDir = rootProject.layout.projectDirectory workingDir = rootProject.layout.projectDirectory
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 893badbe321fa974cb82f5f11ab590bb3827f8b8..4aba540f4bc8014548cc10818472431dfa6b2ede 100644 index eab93e1e3712c0a01cac187bf5944818c813d665..2c24ffd1be2187e1e6fae45122b704515d36777f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1708,7 +1708,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1709,7 +1709,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@DontObfuscate @DontObfuscate
public String getServerModName() { public String getServerModName() {
@@ -55,10 +55,10 @@ index 893badbe321fa974cb82f5f11ab590bb3827f8b8..4aba540f4bc8014548cc10818472431d
public SystemReport fillSystemReport(SystemReport details) { public SystemReport fillSystemReport(SystemReport details) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d938dc26886aa8a64c11db5e49fe5639bc27e1fb..d941957dee45911626f62e55f598490a60d6c818 100644 index 1a1f5c8f9a049d65043f12374fe694068f7d08cf..e110dd95d39a1b7f5860b58170c789c64ea559f4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -255,7 +255,7 @@ import javax.annotation.Nullable; // Paper @@ -254,7 +254,7 @@ import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper import javax.annotation.Nonnull; // Paper
public final class CraftServer implements Server { public final class CraftServer implements Server {
@@ -68,7 +68,7 @@ index d938dc26886aa8a64c11db5e49fe5639bc27e1fb..d941957dee45911626f62e55f598490a
private final String bukkitVersion = Versioning.getBukkitVersion(); private final String bukkitVersion = Versioning.getBukkitVersion();
private final Logger logger = Logger.getLogger("Minecraft"); private final Logger logger = Logger.getLogger("Minecraft");
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index 774556a62eb240da42e84db4502e2ed43495be17..21f39bd0c33ef2635249298e6a247afba8b05742 100644 index 774556a62eb240da42e84db4502e2ed43495be17..9bc7b99b5b39a8ffe4118b8d86f5b8065c4fe460 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
@@ -11,7 +11,7 @@ public final class Versioning { @@ -11,7 +11,7 @@ public final class Versioning {

View File

@@ -1,118 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrPowerGamerBR <git@mrpowergamerbr.com>
Date: Thu, 2 Dec 2021 22:54:36 -0300
Subject: [PATCH] Fix NotePlayEvent
diff --git a/src/main/java/net/minecraft/world/level/block/NoteBlock.java b/src/main/java/net/minecraft/world/level/block/NoteBlock.java
index 16e11e31077f160198e0b04abdfeabb97ed20c6f..b74da21b82ba8d82b2aea7d778f708c4cc689469 100644
--- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java
@@ -60,10 +60,8 @@ public class NoteBlock extends Block {
private void playNote(Level world, BlockPos blockposition, BlockState data) { // CraftBukkit
if (world.getBlockState(blockposition.above()).isAir()) {
// CraftBukkit start
- org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.getValue(NoteBlock.INSTRUMENT), data.getValue(NoteBlock.NOTE));
- if (!event.isCancelled()) {
- world.blockEvent(blockposition, this, 0, 0);
- }
+ // Paper start - move NotePlayEvent call to fix instrument/note changes
+ world.blockEvent(blockposition, this, 0, 0);
// CraftBukkit end
}
@@ -92,10 +90,14 @@ public class NoteBlock extends Block {
@Override
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int type, int data) {
- int k = (Integer) state.getValue(NoteBlock.NOTE);
+ // Paper start - move NotePlayEvent call to fix instrument/note changes
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, pos, state.getValue(INSTRUMENT), state.getValue(NOTE));
+ if (!event.callEvent()) return false;
+ int k = event.getNote().getId();
float f = (float) Math.pow(2.0D, (double) (k - 12) / 12.0D);
- world.playSound((Player) null, pos, ((NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT)).getSoundEvent(), SoundSource.RECORDS, 3.0F, f);
+ world.playSound(null, pos, org.bukkit.craftbukkit.util.CraftMagicNumbers.getNoteBlockInstrument(event.getInstrument()).getSoundEvent(), SoundSource.RECORDS, 3.0F, f);
+ // Paper end
world.addParticle(ParticleTypes.NOTE, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.2D, (double) pos.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
return true;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index d51c63496b55d64ac7ee6175bc364012df897891..d4d592bf4c5055774d1c985f17088fc537cac47d 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -118,6 +118,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
// Paper start
private static final Map<org.bukkit.entity.EntityType, net.minecraft.world.entity.EntityType<?>> ENTITY_TYPE_ENTITY_TYPES = new HashMap<>();
private static final Map<net.minecraft.world.entity.EntityType<?>, org.bukkit.entity.EntityType> ENTITY_TYPES_ENTITY_TYPE = new HashMap<>();
+ private static final com.google.common.collect.BiMap<org.bukkit.Instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument> INSTRUMENT_NOTE_BLOCK_INSTRUMENT = com.google.common.collect.EnumBiMap.create(org.bukkit.Instrument.class, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class);
static {
for (org.bukkit.entity.EntityType type : org.bukkit.entity.EntityType.values()) {
@@ -125,6 +126,16 @@ public final class CraftMagicNumbers implements UnsafeValues {
ENTITY_TYPE_ENTITY_TYPES.put(type, net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())));
ENTITY_TYPES_ENTITY_TYPE.put(net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())), type);
}
+ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.PIANO, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.HARP);
+ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.BASS_DRUM, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.BASEDRUM);
+ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.SNARE_DRUM, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.SNARE);
+ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.STICKS, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.HAT);
+ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(org.bukkit.Instrument.BASS_GUITAR, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.BASS);
+ for (org.bukkit.Instrument instrument : org.bukkit.Instrument.values()) {
+ if (!INSTRUMENT_NOTE_BLOCK_INSTRUMENT.containsKey(instrument)) {
+ INSTRUMENT_NOTE_BLOCK_INSTRUMENT.put(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.valueOf(instrument.name()));
+ }
+ }
// Paper end
for (Block block : net.minecraft.core.Registry.BLOCK) {
BLOCK_MATERIAL.put(block, Material.getMaterial(net.minecraft.core.Registry.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT)));
@@ -198,6 +209,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
public static org.bukkit.entity.EntityType getEntityType(net.minecraft.world.entity.EntityType<?> entityTypes) {
return ENTITY_TYPES_ENTITY_TYPE.get(entityTypes);
}
+ public static net.minecraft.world.level.block.state.properties.NoteBlockInstrument getNoteBlockInstrument(org.bukkit.Instrument instrument) {
+ return INSTRUMENT_NOTE_BLOCK_INSTRUMENT.get(instrument);
+ }
+ public static org.bukkit.Instrument getInstrument(net.minecraft.world.level.block.state.properties.NoteBlockInstrument instrument) {
+ return INSTRUMENT_NOTE_BLOCK_INSTRUMENT.inverse().get(instrument);
+ }
// Paper end
// ========================================================================
// Paper start
diff --git a/src/test/java/org/bukkit/InstrumentTest.java b/src/test/java/org/bukkit/InstrumentTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ae9b55ae367313f3f5e5a941b4620aba6623c262
--- /dev/null
+++ b/src/test/java/org/bukkit/InstrumentTest.java
@@ -0,0 +1,29 @@
+package org.bukkit;
+
+import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+public class InstrumentTest {
+
+ @Test
+ public void testGetNoteBlockInstrument() {
+ // ensure there is a NoteBlockInstrument for each Instrument
+ for (Instrument instrument : Instrument.values()) {
+ NoteBlockInstrument noteBlockInstrument = CraftMagicNumbers.getNoteBlockInstrument(instrument);
+ assertNotNull("no NoteBlockInstrument for Instrument " + instrument.name(), noteBlockInstrument);
+ }
+ }
+
+ @Test
+ public void testGetInstrument() {
+ // ensure there is an Instrument for each NoteBlockInstrument
+ for (NoteBlockInstrument noteBlockInstrument : NoteBlockInstrument.values()) {
+ Instrument instrument = CraftMagicNumbers.getInstrument(noteBlockInstrument);
+ assertNotNull("no Instrument for NoteBlockInstrument " + noteBlockInstrument.name(), instrument);
+ }
+ }
+
+}
\ No newline at end of file

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] More note block events
From Haricot, thanks Kezz! https://github.com/kezz/Haricot/blob/dffbe897cd6db773c06cfad6304e20b54c7aa980/patches/server/0005-More-note-block-events.patch From Haricot, thanks Kezz! https://github.com/kezz/Haricot/blob/dffbe897cd6db773c06cfad6304e20b54c7aa980/patches/server/0005-More-note-block-events.patch
diff --git a/src/main/java/net/minecraft/world/level/block/NoteBlock.java b/src/main/java/net/minecraft/world/level/block/NoteBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/NoteBlock.java b/src/main/java/net/minecraft/world/level/block/NoteBlock.java
index b74da21b82ba8d82b2aea7d778f708c4cc689469..b45345e73b9a05e87a0dae4c56f27e725bfbede8 100644 index 0e106bcc1f882877a5e444a2621466c6e4696d42..ca11f7a9f7f79e3050f351bb433dbf31f0738393 100644
--- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java --- a/src/main/java/net/minecraft/world/level/block/NoteBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java +++ b/src/main/java/net/minecraft/world/level/block/NoteBlock.java
@@ -20,6 +20,12 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; @@ -20,6 +20,12 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
@@ -81,7 +81,7 @@ index b74da21b82ba8d82b2aea7d778f708c4cc689469..b45345e73b9a05e87a0dae4c56f27e72
} }
} }
@@ -72,10 +113,23 @@ public class NoteBlock extends Block { @@ -73,10 +114,23 @@ public class NoteBlock extends Block {
if (world.isClientSide) { if (world.isClientSide) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {