diff options
author | Bjarne Koll <[email protected]> | 2024-06-13 22:26:40 +0200 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-06-14 14:37:17 -0700 |
commit | d5477705a262bb1700b1d4c2466b8d723dd5d488 (patch) | |
tree | 66f9676d624006633a9e293ca7fef9cf307e5773 | |
parent | adb14efc6680f703a73f16b123718de657280dd0 (diff) | |
download | Paper-d5477705a262bb1700b1d4c2466b8d723dd5d488.tar.gz Paper-d5477705a262bb1700b1d4c2466b8d723dd5d488.zip |
Drop specific entry modification for later PR
-rw-r--r-- | patches/api/0485-Support-registry-mod-API-with-GameEvent.patch | 90 | ||||
-rw-r--r-- | patches/server/1055-Support-registry-mod-API-with-GameEvent.patch | 93 |
2 files changed, 0 insertions, 183 deletions
diff --git a/patches/api/0485-Support-registry-mod-API-with-GameEvent.patch b/patches/api/0485-Support-registry-mod-API-with-GameEvent.patch deleted file mode 100644 index 00811c3e8a..0000000000 --- a/patches/api/0485-Support-registry-mod-API-with-GameEvent.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Sat, 25 Feb 2023 21:26:44 -0800 -Subject: [PATCH] Support registry mod API with GameEvent - - -diff --git a/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java b/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java -index 1f89945be2ed68f52a544f41f7a151b8fdfe113e..ae9f8e7c7e37ca242f4d158da6f5461201a47589 100644 ---- a/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java -+++ b/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java -@@ -1,7 +1,11 @@ - package io.papermc.paper.registry.event; - -+import io.papermc.paper.registry.RegistryKey; -+import org.bukkit.GameEvent; - import org.jetbrains.annotations.ApiStatus; - -+import static io.papermc.paper.registry.event.RegistryEventProviderImpl.create; -+ - /** - * Holds providers for {@link RegistryEntryAddEvent} and {@link RegistryFreezeEvent} - * handlers for each applicable registry. -@@ -9,6 +13,8 @@ import org.jetbrains.annotations.ApiStatus; - @ApiStatus.Experimental - public final class RegistryEvents { - -+ public static final RegistryEventProvider<GameEvent, GameEvent.Builder> GAME_EVENT = create(RegistryKey.GAME_EVENT); -+ - private RegistryEvents() { - } - } -diff --git a/src/main/java/org/bukkit/GameEvent.java b/src/main/java/org/bukkit/GameEvent.java -index 6c9689baca1763e2ef79495d38618d587e792434..fd9ccb69f99ae77da66583770e994cd958fd4bf9 100644 ---- a/src/main/java/org/bukkit/GameEvent.java -+++ b/src/main/java/org/bukkit/GameEvent.java -@@ -10,6 +10,7 @@ import org.jetbrains.annotations.Nullable; - /** - * Represents a generic Mojang game event. - */ [email protected](NotNull.class) // Paper - public abstract class GameEvent implements Keyed { - - public static final GameEvent BLOCK_ACTIVATE = getEvent("block_activate"); -@@ -147,4 +148,46 @@ public abstract class GameEvent implements Keyed { - - return gameEvent; - } -+ -+ // Paper start -+ /** -+ * Gets the range of the event which is used to -+ * notify listeners of the event. -+ * -+ * @return the range -+ */ -+ public abstract int getRange(); -+ -+ /** -+ * Gets the vibration level of the game event for vibration listeners. -+ * Not all events have vibration levels, and a level of 0 means -+ * it won't cause any vibrations. -+ * -+ * @return the vibration level -+ */ -+ public abstract int getVibrationLevel(); -+ -+ @org.jetbrains.annotations.ApiStatus.Experimental -+ @org.jetbrains.annotations.ApiStatus.NonExtendable -+ public interface Builder extends io.papermc.paper.registry.RegistryBuilder<GameEvent> { -+ -+ /** -+ * Gets the range of the event which is used to -+ * notify listeners of the event. -+ * -+ * @return the range -+ */ -+ int range(); -+ -+ /** -+ * Sets the range of the event which is used to -+ * notify listeners of the event. -+ * -+ * @param range the range -+ * @return the builder -+ */ -+ @org.jetbrains.annotations.Contract("_ -> this") -+ @NotNull Builder range(int range); -+ } -+ // Paper end - } diff --git a/patches/server/1055-Support-registry-mod-API-with-GameEvent.patch b/patches/server/1055-Support-registry-mod-API-with-GameEvent.patch deleted file mode 100644 index 90a05120b1..0000000000 --- a/patches/server/1055-Support-registry-mod-API-with-GameEvent.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Sat, 25 Feb 2023 21:25:08 -0800 -Subject: [PATCH] Support registry mod API with GameEvent - - -diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java -index 9342f034ef590594db046cd9b0810bd4075d8e6b..6c83c097cf7c9d0b985ca4f6abdb1db4de0140cc 100644 ---- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java -+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java -@@ -60,7 +60,7 @@ public final class PaperRegistries { - REGISTRY_ENTRIES = List.of( - // built-ins - entry(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME), -- entry(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new), -+ writable(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new, CraftGameEvent.Builder::new), - entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new), - entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new), - entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new), -diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEvent.java b/src/main/java/net/minecraft/world/level/gameevent/GameEvent.java -index ef0eecd4404fcce4046b53ff9e176ea59978d1ac..c4f8a03aac42507df2d9a84b3acf53887d2eed86 100644 ---- a/src/main/java/net/minecraft/world/level/gameevent/GameEvent.java -+++ b/src/main/java/net/minecraft/world/level/gameevent/GameEvent.java -@@ -81,7 +81,7 @@ public record GameEvent(int notificationRadius) { - } - - private static Holder.Reference<GameEvent> register(String id, int range) { -- return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, new ResourceLocation(id), new GameEvent(range)); -+ return io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerForHolderWithListeners(BuiltInRegistries.GAME_EVENT, new ResourceLocation(id), new GameEvent(range)); // Paper - } - - public static record Context(@Nullable Entity sourceEntity, @Nullable BlockState affectedState) { -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java b/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java -index ac9b4328cd55a68664a3f71186bc9a7be7cd9658..34c63a685606a55936f27dfe4393d23e46d8d20d 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java -@@ -19,10 +19,12 @@ public class CraftGameEvent extends GameEvent implements Handleable<net.minecraf - - private final NamespacedKey key; - private final net.minecraft.world.level.gameevent.GameEvent handle; -+ private final net.minecraft.resources.ResourceKey<net.minecraft.world.level.gameevent.GameEvent> handleKey; // Paper - - public CraftGameEvent(NamespacedKey key, net.minecraft.world.level.gameevent.GameEvent handle) { - this.key = key; - this.handle = handle; -+ this.handleKey = net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.GAME_EVENT, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(this.key)); // Paper - } - - @Override -@@ -58,4 +60,43 @@ public class CraftGameEvent extends GameEvent implements Handleable<net.minecraf - public String toString() { - return "CraftGameEvent{key=" + this.key + "}"; - } -+ -+ // Paper start -+ @Override -+ public int getRange() { -+ return this.handle.notificationRadius(); -+ } -+ -+ @Override -+ public int getVibrationLevel() { -+ return net.minecraft.world.level.gameevent.vibrations.VibrationSystem.getGameEventFrequency(this.handleKey); -+ } -+ -+ public static final class Builder implements GameEvent.Builder, io.papermc.paper.registry.PaperRegistryBuilder<net.minecraft.world.level.gameevent.GameEvent, org.bukkit.GameEvent> { -+ -+ private int range = 16; -+ -+ public Builder(final io.papermc.paper.registry.TypedKey<GameEvent> $, final net.minecraft.world.level.gameevent.@org.checkerframework.checker.nullness.qual.Nullable GameEvent nms) { -+ if (nms != null) { -+ this.range = nms.notificationRadius(); -+ } -+ } -+ -+ @Override -+ public int range() { -+ return this.range; -+ } -+ -+ @Override -+ public Builder range(final int range) { -+ this.range = range; -+ return this; -+ } -+ -+ @Override -+ public net.minecraft.world.level.gameevent.GameEvent build() { -+ return new net.minecraft.world.level.gameevent.GameEvent(this.range); -+ } -+ } -+ // Paper end - } |