diff --git a/patches/api/Add-GameEvent-tags.patch b/patches/api/Add-GameEvent-tags.patch new file mode 100644 index 0000000000..a06718de7f --- /dev/null +++ b/patches/api/Add-GameEvent-tags.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <jake.m.potrebic@gmail.com> +Date: Sat, 18 Dec 2021 10:34:21 -0800 +Subject: [PATCH] Add GameEvent tags + + +diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Tag.java ++++ b/src/main/java/org/bukkit/Tag.java +@@ -0,0 +0,0 @@ public interface Tag<T extends Keyed> extends Keyed { + */ + @Deprecated(forRemoval = true) + Tag<EntityType> SKELETONS = ENTITY_TYPES_SKELETONS; ++ ++ String REGISTRY_GAME_EVENTS = "game_events"; ++ ++ /** ++ * Tag for game events that trigger sculk sensors ++ */ ++ Tag<GameEvent> GAME_EVENT_VIBRATIONS = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("vibrations"), GameEvent.class); ++ ++ /** ++ * Tag for game events that are ignored if the entity is sneaking ++ */ ++ Tag<GameEvent> GAME_EVENT_IGNORE_VIBRATIONS_SNEAKING = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("ignore_vibrations_sneaking"), GameEvent.class); + // Paper end + + /** diff --git a/patches/server/Add-GameEvent-tags.patch b/patches/server/Add-GameEvent-tags.patch new file mode 100644 index 0000000000..b4fb687a14 --- /dev/null +++ b/patches/server/Add-GameEvent-tags.patch @@ -0,0 +1,74 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <jake.m.potrebic@gmail.com> +Date: Sun, 3 Jan 2021 20:03:35 -0800 +Subject: [PATCH] Add GameEvent tags + + +diff --git a/src/main/java/io/papermc/paper/CraftGameEventTag.java b/src/main/java/io/papermc/paper/CraftGameEventTag.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/CraftGameEventTag.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper; ++ ++import net.minecraft.core.Registry; ++import net.minecraft.resources.ResourceLocation; ++import net.minecraft.tags.TagCollection; ++import org.bukkit.GameEvent; ++import org.bukkit.craftbukkit.tag.CraftTag; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.jetbrains.annotations.NotNull; ++ ++import java.util.Collections; ++import java.util.Objects; ++import java.util.Set; ++import java.util.stream.Collectors; ++ ++public class CraftGameEventTag extends CraftTag<net.minecraft.world.level.gameevent.GameEvent, GameEvent> { ++ ++ public CraftGameEventTag(TagCollection<net.minecraft.world.level.gameevent.GameEvent> registry, ResourceLocation tag) { ++ super(registry, tag); ++ } ++ ++ @Override ++ public boolean isTagged(@NotNull GameEvent item) { ++ return this.getHandle().contains(Registry.GAME_EVENT.get(CraftNamespacedKey.toMinecraft(item.getKey()))); ++ } ++ ++ @Override ++ public @NotNull Set<GameEvent> getValues() { ++ return this.getHandle().getValues().stream().map(ge -> Objects.requireNonNull(GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(Registry.GAME_EVENT.getKey(ge))), ge + " is not a recognized game event")).collect(Collectors.toUnmodifiableSet()); ++ } ++} +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); + + return (org.bukkit.Tag<T>) new CraftEntityTag(EntityTypeTags.getAllTags(), key); ++ // Paper start ++ case org.bukkit.Tag.REGISTRY_GAME_EVENTS: ++ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class, "Game Event namespace must have GameEvent type"); ++ ++ return (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(net.minecraft.tags.GameEventTags.getAllTags(), key); ++ // Paper end + default: + throw new IllegalArgumentException(); + } +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + + TagCollection<EntityType<?>> entityTags = EntityTypeTags.getAllTags(); + return entityTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList()); ++ // Paper start ++ case org.bukkit.Tag.REGISTRY_GAME_EVENTS: ++ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class); ++ ++ TagCollection<net.minecraft.world.level.gameevent.GameEvent> gameEvents = net.minecraft.tags.GameEventTags.getAllTags(); ++ return gameEvents.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(gameEvents, key)).toList(); ++ // Paper end + default: + throw new IllegalArgumentException(); + }