aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server')
-rw-r--r--patches/server/0406-Add-methods-to-get-translation-keys.patch22
-rw-r--r--patches/server/0536-More-Enchantment-API.patch32
-rw-r--r--patches/server/1048-Add-even-more-Enchantment-API.patch47
3 files changed, 79 insertions, 22 deletions
diff --git a/patches/server/0406-Add-methods-to-get-translation-keys.patch b/patches/server/0406-Add-methods-to-get-translation-keys.patch
index e8e4f5ac2d..5b5a9288df 100644
--- a/patches/server/0406-Add-methods-to-get-translation-keys.patch
+++ b/patches/server/0406-Add-methods-to-get-translation-keys.patch
@@ -42,21 +42,27 @@ index 338a8f4acf413ef24fedab60c19c7a51a0ea19a6..2d8a509446c0ed0d7358f10f67ef29c4
+ // Paper end - add Translatable
}
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
-index f73017bff613bd62b86c974b29576e241c24c927..fc6606e1bf2e2c35cb6c84af78859c3441775907 100644
+index f73017bff613bd62b86c974b29576e241c24c927..59c9c970b83f62245d860994c4ac0c21dcc15398 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
-@@ -150,6 +150,11 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
- public net.kyori.adventure.text.Component displayName(int level) {
- return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
+@@ -152,6 +152,17 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
}
-+
+ // Paper end
+
++ // Paper start - add translationKey methods
+ @Override
+ public String translationKey() {
-+ return this.handle.getDescriptionId();
++ if (!(this.getHandle().description().getContents() instanceof final net.minecraft.network.chat.contents.TranslatableContents translatableContents)) {
++ throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
++ }
++ return translatableContents.getKey();
++
+ }
- // Paper end
-
++ // Paper end - add translationKey methods
++
@Override
+ public String getTranslationKey() {
+ return Util.makeDescriptionId("enchantment", this.handle.unwrapKey().get().location());
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
index d20fdd4f06faa09c7d9f9e04f379cf0fa68db9bb..66d773cadb74f9176e6cf68a565568034f52ec63 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
diff --git a/patches/server/0536-More-Enchantment-API.patch b/patches/server/0536-More-Enchantment-API.patch
index 692f90b66a..a3bf8f8e7e 100644
--- a/patches/server/0536-More-Enchantment-API.patch
+++ b/patches/server/0536-More-Enchantment-API.patch
@@ -10,7 +10,7 @@ Co-authored-by: Luis <[email protected]>
Co-authored-by: Janet Blackquill <[email protected]>
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
-index fc6606e1bf2e2c35cb6c84af78859c3441775907..edf4df4d13dc814e98b897a3f8a5fd4757284299 100644
+index 59c9c970b83f62245d860994c4ac0c21dcc15398..4221a1e9cba35c8dc58e51e162e7fcbd0e8b31af 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@@ -5,6 +5,7 @@ import java.util.Locale;
@@ -30,23 +30,24 @@ index fc6606e1bf2e2c35cb6c84af78859c3441775907..edf4df4d13dc814e98b897a3f8a5fd47
}
@Override
-@@ -148,12 +149,66 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
+@@ -148,7 +149,7 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
// Paper start
@Override
public net.kyori.adventure.text.Component displayName(int level) {
- return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.world.item.enchantment.Enchantment.getFullname(this.handle, level));
}
+ // Paper end
- @Override
- public String translationKey() {
-- return this.handle.getDescriptionId();
-+ if (!(this.getHandle().description().getContents() instanceof final TranslatableContents translatableContents)) {
-+ throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
-+ }
-+ return translatableContents.getKey();
-+ }
-+
+@@ -159,10 +160,62 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
+ throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
+ }
+ return translatableContents.getKey();
+-
+ }
+ // Paper end - add translationKey methods
+
++ // Paper start - more Enchantment API
+ @Override
+ public boolean isTradeable() {
+ return this.handle.is(EnchantmentTags.TRADEABLE);
@@ -96,6 +97,9 @@ index fc6606e1bf2e2c35cb6c84af78859c3441775907..edf4df4d13dc814e98b897a3f8a5fd47
+ return this.getHandle().definition().slots().stream()
+ .map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot)
+ .collect(java.util.stream.Collectors.toSet());
- }
- // Paper end
-
++ }
++ // Paper end - more Enchantment API
++
+ @Override
+ public String getTranslationKey() {
+ return Util.makeDescriptionId("enchantment", this.handle.unwrapKey().get().location());
diff --git a/patches/server/1048-Add-even-more-Enchantment-API.patch b/patches/server/1048-Add-even-more-Enchantment-API.patch
new file mode 100644
index 0000000000..dfc79b5b19
--- /dev/null
+++ b/patches/server/1048-Add-even-more-Enchantment-API.patch
@@ -0,0 +1,47 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Fri, 19 Jul 2024 08:42:45 -0700
+Subject: [PATCH] Add even more Enchantment API
+
+In a separate patch because RegistryKeySet is used
+and the previous "more enchant api" patch is before that.
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+index 4221a1e9cba35c8dc58e51e162e7fcbd0e8b31af..34934f0dbe66ee200cd99c002c53645660041548 100644
+--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
++++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+@@ -216,6 +216,34 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
+ }
+ // Paper end - more Enchantment API
+
++ // Paper start - even more Enchantment API
++ @Override
++ public net.kyori.adventure.text.Component description() {
++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.value().description());
++ }
++
++ @Override
++ public io.papermc.paper.registry.set.RegistryKeySet<org.bukkit.inventory.ItemType> getSupportedItems() {
++ return io.papermc.paper.registry.set.PaperRegistrySets.convertToApi(io.papermc.paper.registry.RegistryKey.ITEM, this.handle.value().getSupportedItems());
++ }
++
++ @Override
++ public io.papermc.paper.registry.set.RegistryKeySet<org.bukkit.inventory.ItemType> getPrimaryItems() {
++ final java.util.Optional<net.minecraft.core.HolderSet<net.minecraft.world.item.Item>> primaryItems = this.handle.value().definition().primaryItems();
++ return primaryItems.map(holders -> io.papermc.paper.registry.set.PaperRegistrySets.convertToApi(io.papermc.paper.registry.RegistryKey.ITEM, holders)).orElse(null);
++ }
++
++ @Override
++ public int getWeight() {
++ return this.handle.value().getWeight();
++ }
++
++ @Override
++ public io.papermc.paper.registry.set.RegistryKeySet<org.bukkit.enchantments.Enchantment> getExclusiveWith() {
++ return io.papermc.paper.registry.set.PaperRegistrySets.convertToApi(io.papermc.paper.registry.RegistryKey.ENCHANTMENT, this.handle.value().exclusiveSet());
++ }
++ // Paper end - even more Enchantment API
++
+ @Override
+ public String getTranslationKey() {
+ return Util.makeDescriptionId("enchantment", this.handle.unwrapKey().get().location());