aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjarne Koll <[email protected]>2024-06-13 11:03:56 +0200
committerBjarne Koll <[email protected]>2024-06-13 11:03:56 +0200
commita21ed1357000bff9da0dd725dc62e2fda589c1a0 (patch)
tree6f0f5cbe8bf8e1cd30645b2e5ba49032bd3f480d
parent3231054193bceac7085f2fa45eded0a01768088e (diff)
downloadPaper-a21ed1357000bff9da0dd725dc62e2fda589c1a0.tar.gz
Paper-a21ed1357000bff9da0dd725dc62e2fda589c1a0.zip
Initial work towards material rerouting
-rw-r--r--patches/api/0152-Add-Material-Tags.patch14
-rw-r--r--patches/server/1053-Adopt-MaterialRerouting.patch60
2 files changed, 70 insertions, 4 deletions
diff --git a/patches/api/0152-Add-Material-Tags.patch b/patches/api/0152-Add-Material-Tags.patch
index 00b8a36df3..624dd5825b 100644
--- a/patches/api/0152-Add-Material-Tags.patch
+++ b/patches/api/0152-Add-Material-Tags.patch
@@ -12,10 +12,10 @@ Co-authored-by: Layla Silbernberg <[email protected]>
diff --git a/src/main/java/com/destroystokyo/paper/MaterialSetTag.java b/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
new file mode 100644
-index 0000000000000000000000000000000000000000..a02a02aa0c87e0f0ed9e509e4dcab01565b3d92a
+index 0000000000000000000000000000000000000000..28282090c8b3668c11faefa0523f9e4ad9e43c42
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/MaterialSetTag.java
-@@ -0,0 +1,97 @@
+@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
+ */
@@ -36,6 +36,7 @@ index 0000000000000000000000000000000000000000..a02a02aa0c87e0f0ed9e509e4dcab015
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
++import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@@ -83,12 +84,14 @@ index 0000000000000000000000000000000000000000..a02a02aa0c87e0f0ed9e509e4dcab015
+
+ @NotNull
+ @Override
++ @ApiStatus.Internal
+ protected Set<Material> getAllPossibleValues() {
+ return Stream.of(Material.values()).collect(Collectors.toSet());
+ }
+
+ @Override
+ @NotNull
++ @ApiStatus.Internal
+ protected String getName(@NotNull Material value) {
+ return value.name();
+ }
@@ -838,10 +841,10 @@ index 0000000000000000000000000000000000000000..be212b4fbeabab32a4dab6ae554768c3
+}
diff --git a/src/main/java/io/papermc/paper/tag/BaseTag.java b/src/main/java/io/papermc/paper/tag/BaseTag.java
new file mode 100644
-index 0000000000000000000000000000000000000000..794787912325ae32b3cfc8217bc3fc2159ceabd5
+index 0000000000000000000000000000000000000000..262b7f7e2c3cf39006392dd5197d4595a0bfb507
--- /dev/null
+++ b/src/main/java/io/papermc/paper/tag/BaseTag.java
-@@ -0,0 +1,181 @@
+@@ -0,0 +1,184 @@
+package io.papermc.paper.tag;
+
+import com.google.common.collect.Lists;
@@ -849,6 +852,7 @@ index 0000000000000000000000000000000000000000..794787912325ae32b3cfc8217bc3fc21
+import org.bukkit.Keyed;
+import org.bukkit.NamespacedKey;
+import org.bukkit.Tag;
++import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
@@ -1018,9 +1022,11 @@ index 0000000000000000000000000000000000000000..794787912325ae32b3cfc8217bc3fc21
+ }
+
+ @NotNull
++ @ApiStatus.Internal
+ protected abstract Set<T> getAllPossibleValues();
+
+ @NotNull
++ @ApiStatus.Internal
+ protected abstract String getName(@NotNull T value);
+}
diff --git a/src/main/java/io/papermc/paper/tag/EntitySetTag.java b/src/main/java/io/papermc/paper/tag/EntitySetTag.java
diff --git a/patches/server/1053-Adopt-MaterialRerouting.patch b/patches/server/1053-Adopt-MaterialRerouting.patch
new file mode 100644
index 0000000000..29760fa722
--- /dev/null
+++ b/patches/server/1053-Adopt-MaterialRerouting.patch
@@ -0,0 +1,60 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Bjarne Koll <[email protected]>
+Date: Thu, 13 Jun 2024 11:02:36 +0200
+Subject: [PATCH] Adopt MaterialRerouting
+
+Adopts the paper-api to the material rerouting infrastructure introduced
+by upstream.
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/MaterialRerouting.java b/src/main/java/org/bukkit/craftbukkit/legacy/MaterialRerouting.java
+index 3ff0f0e34356cee4c510fdd60af723b1c5df156a..deb121526016b0bffa8346e3074503fab9ef7c31 100644
+--- a/src/main/java/org/bukkit/craftbukkit/legacy/MaterialRerouting.java
++++ b/src/main/java/org/bukkit/craftbukkit/legacy/MaterialRerouting.java
+@@ -600,4 +600,8 @@ public class MaterialRerouting {
+ public static void setBlocks(ToolComponent.ToolRule toolRule, Collection<Material> blocks) {
+ toolRule.setBlocks(blocks.stream().map(MaterialRerouting::transformToBlockType).toList());
+ }
++
++ // Paper start - register paper API specific material consumers in rerouting
++
++ // Paper end - register paper API specific material consumers in rerouting
+ }
+diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.java
+index 26208ca74688be062584824de5d074321b33f1b1..946cd46f3389a4d4ceda86e0115c59c5725a8a0a 100644
+--- a/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.java
++++ b/src/test/java/org/bukkit/craftbukkit/legacy/MaterialReroutingTest.java
+@@ -55,6 +55,9 @@ public class MaterialReroutingTest extends AbstractTestingBase {
+ .filter(entry -> !entry.getName().endsWith("ItemType.class"))
+ .filter(entry -> !entry.getName().endsWith("Registry.class"))
+ .filter(entry -> !entry.getName().startsWith("org/bukkit/material"))
++ // Paper start - types that cannot be translated to ItemType/BlockType
++ .filter(entry -> !entry.getName().equals("com/destroystokyo/paper/MaterialSetTag.class"))
++ // Paper end - types that cannot be translated to ItemType/BlockType
+ .map(entry -> {
+ try {
+ return MaterialReroutingTest.jarFile.getInputStream(entry);
+@@ -92,6 +95,10 @@ public class MaterialReroutingTest extends AbstractTestingBase {
+ continue;
+ }
+ }
++ // Paper start - filter out more methods from rerouting test
++ if (methodNode.name.startsWith("lambda$")) continue;
++ if (isInternal(methodNode.invisibleAnnotations)) continue;
++ // Paper end - filter out more methods from rerouting test
+
+ if (!Commodore.rerouteMethods(Collections.emptySet(), MaterialReroutingTest.MATERIAL_METHOD_REROUTE, (methodNode.access & Opcodes.ACC_STATIC) != 0, classNode.name, methodNode.name, methodNode.desc, a -> { })) {
+ missingReroute.add(methodNode.name + " " + methodNode.desc + " " + methodNode.signature);
+@@ -108,6 +115,13 @@ public class MaterialReroutingTest extends AbstractTestingBase {
+ }
+ }
+
++ // Paper start - filter out more methods from rerouting test
++ private static boolean isInternal(final List<org.objectweb.asm.tree.AnnotationNode> annotationNodes) {
++ return annotationNodes != null
++ && annotationNodes.stream().anyMatch(a -> a.desc.equals("Lorg/jetbrains/annotations/ApiStatus$Internal;"));
++ }
++ // Paper end - filter out more methods from rerouting test
++
+ @AfterAll
+ public static void clear() throws IOException {
+ if (MaterialReroutingTest.jarFile != null) {