[ci skip] Move logic in our patches to ItemType/BlockType (#10772)

This commit is contained in:
Jake Potrebic 2024-05-23 10:32:02 -07:00 committed by GitHub
parent b14958485d
commit a9201d4a7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 208 additions and 108 deletions

View File

@ -144,7 +144,7 @@ index dc66bd69646ac949d1386ce8f6ff913e9475439d..4482e8f2c617c2f51b2b53762e775d11
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index feebabf946913263461e1d0f13a478cf4bfd0f68..d6e2ec415eab4f55fd925a3b0982e869befbd088 100644
index feebabf946913263461e1d0f13a478cf4bfd0f68..ebf505bbdc1b44d1fcd3c30f4143f6e5b89d09e9 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -129,7 +129,7 @@ import org.jetbrains.annotations.Nullable;
@ -156,23 +156,25 @@ index feebabf946913263461e1d0f13a478cf4bfd0f68..d6e2ec415eab4f55fd925a3b0982e869
//<editor-fold desc="Materials" defaultstate="collapsed">
AIR(9648, 0),
STONE(22948),
@@ -4743,6 +4743,15 @@ public enum Material implements Keyed, Translatable {
}
return false;
@@ -4745,6 +4745,17 @@ public enum Material implements Keyed, Translatable {
}
+
// Paper end
+ // Paper start - add Translatable
+ @Override
+ public @NotNull String translationKey() {
+ if (this.isItem()) {
+ return Bukkit.getUnsafe().getItemTranslationKey(this);
+ return java.util.Objects.requireNonNull(this.asItemType()).translationKey();
+ } else {
+ return Bukkit.getUnsafe().getBlockTranslationKey(this);
+ return java.util.Objects.requireNonNull(this.asBlockType()).translationKey();
+ }
+ }
// Paper end
+ // Paper end - add Translatable
+
/**
@@ -5494,9 +5503,11 @@ public enum Material implements Keyed, Translatable {
* Do not use for any reason.
*
@@ -5494,9 +5505,11 @@ public enum Material implements Keyed, Translatable {
* material
* @see #getBlockTranslationKey()
* @see #getItemTranslationKey()
@ -309,6 +311,33 @@ index bf29d9b733afc7c62725d259f4920c4f211cc6d0..1d3812db989a55b6f31bb30dffe70323
+ String getTranslationKey();
// Paper end
}
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
index 95cedd536fed5a195fb2dd76da1c451598250f53..d4e824ad18714b951cf161031a9566e6796ab507 100644
--- a/src/main/java/org/bukkit/block/BlockType.java
+++ b/src/main/java/org/bukkit/block/BlockType.java
@@ -125,7 +125,7 @@ import org.jetbrains.annotations.Nullable;
* changes may occur. Do not use this API in plugins.
*/
@ApiStatus.Internal
-public interface BlockType extends Keyed, Translatable {
+public interface BlockType extends Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - add translatable
/**
* Typed represents a subtype of {@link BlockType}s that have a known block
@@ -3602,4 +3602,13 @@ public interface BlockType extends Keyed, Translatable {
@Nullable
@Deprecated
Material asMaterial();
+
+ // Paper start - add Translatable
+ /**
+ * @deprecated use {@link #translationKey()} and {@link net.kyori.adventure.text.Component#translatable(net.kyori.adventure.translation.Translatable)}
+ */
+ @Deprecated(forRemoval = true)
+ @Override
+ @NotNull String getTranslationKey();
+ // Paper end - add Translatable
}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index f4ec7891bdcedc73bff6938e3eddb7ee43d23ec1..4e41980dfbb256356231bc9565f6a90ea66aab76 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
@ -517,3 +546,30 @@ index 066f99a1f4cc42cf0e87d495f97a0685817dfa18..23686519b8c1338dd6e9f1c5a0e73467
+ }
// Paper end
}
diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java
index aa0f66b7187c800cd22905bfa43af3ffb53edb5f..3d30c4957a2950ac8d4635ed7bb9bf39ca8cd158 100644
--- a/src/main/java/org/bukkit/inventory/ItemType.java
+++ b/src/main/java/org/bukkit/inventory/ItemType.java
@@ -49,7 +49,7 @@ import org.jetbrains.annotations.Nullable;
* changes may occur. Do not use this API in plugins.
*/
@ApiStatus.Internal
-public interface ItemType extends Keyed, Translatable {
+public interface ItemType extends Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - add Translatable
/**
* Typed represents a subtype of {@link ItemType}s that have a known item meta type
@@ -2419,4 +2419,13 @@ public interface ItemType extends Keyed, Translatable {
@Nullable
@Deprecated
Material asMaterial();
+
+ // Paper start - add Translatable
+ /**
+ * @deprecated use {@link #translationKey()} and {@link net.kyori.adventure.text.Component#translatable(net.kyori.adventure.translation.Translatable)}
+ */
+ @Deprecated(forRemoval = true)
+ @Override
+ @NotNull String getTranslationKey();
+ // Paper end - add Translatable
}

View File

@ -43,14 +43,14 @@ index 0000000000000000000000000000000000000000..f1cd5a4f37eee8975ac3d0421b524afc
+ }
+}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index d6e2ec415eab4f55fd925a3b0982e869befbd088..044c563daee7898c676bd6ba58ee395c52eda121 100644
index ebf505bbdc1b44d1fcd3c30f4143f6e5b89d09e9..04cb8279f2296cc42405355c7c1f120e761202c4 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4752,6 +4752,19 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
return Bukkit.getUnsafe().getBlockTranslationKey(this);
}
@@ -4756,6 +4756,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
+
// Paper end - add Translatable
+ // Paper start - item rarity API
+ /**
+ * Returns the item rarity for the item. The Material <b>MUST</b> be an Item not a block.
+ * Use {@link #isItem()} before this.
@ -63,9 +63,11 @@ index d6e2ec415eab4f55fd925a3b0982e869befbd088..044c563daee7898c676bd6ba58ee395c
+ public io.papermc.paper.inventory.ItemRarity getItemRarity() {
+ return new org.bukkit.inventory.ItemStack(this).getRarity();
+ }
// Paper end
+ // Paper end - item rarity API
+
/**
* Do not use for any reason.
*
diff --git a/src/main/java/org/bukkit/inventory/ItemRarity.java b/src/main/java/org/bukkit/inventory/ItemRarity.java
index e7931f73f10fe35ebd5fe4a04b036d53bb117ebd..cbce835ed6d44e5b8c9aaae4e36a77f8e5bed45f 100644
--- a/src/main/java/org/bukkit/inventory/ItemRarity.java

View File

@ -6,14 +6,14 @@ Subject: [PATCH] Attributes API for item defaults
(Now replaced by upstream's API)
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 044c563daee7898c676bd6ba58ee395c52eda121..f6c3a4de2f07348d599e44d0b3173b8674ee85ac 100644
index 04cb8279f2296cc42405355c7c1f120e761202c4..1df815c2e430a308baea08c9a7f3ca43377dc16e 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4765,6 +4765,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public io.papermc.paper.inventory.ItemRarity getItemRarity() {
return new org.bukkit.inventory.ItemStack(this).getRarity();
@@ -4771,6 +4771,23 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
+
// Paper end - item rarity API
+ // Paper start - item default attributes API
+ /**
+ * Returns an immutable multimap of attributes for the slot.
+ * {@link #isItem()} must be true for this material.
@ -28,6 +28,8 @@ index 044c563daee7898c676bd6ba58ee395c52eda121..f6c3a4de2f07348d599e44d0b3173b86
+ public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
+ return this.getDefaultAttributeModifiers(equipmentSlot);
+ }
// Paper end
+ // Paper end - item default attributes API
+
/**
* Do not use for any reason.
*

View File

@ -1,18 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 4 Nov 2021 11:50:35 -0700
Subject: [PATCH] Add isCollidable methods to various places
Subject: [PATCH] Add hasCollision methods to various places
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index f6c3a4de2f07348d599e44d0b3173b8674ee85ac..4ad5f2d40c10e7b059a9096dcc6a3b0b618411a0 100644
index 1df815c2e430a308baea08c9a7f3ca43377dc16e..195bd298cfc2d43720550d5bf5a3347c064e9a7a 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4780,6 +4780,16 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
return this.getDefaultAttributeModifiers(equipmentSlot);
@@ -4788,6 +4788,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
+
// Paper end - item default attributes API
+ // Paper start - isCollidable API
+ /**
+ * Checks if this material is collidable.
+ *
@ -20,30 +20,16 @@ index f6c3a4de2f07348d599e44d0b3173b8674ee85ac..4ad5f2d40c10e7b059a9096dcc6a3b0b
+ * @throws IllegalArgumentException if {@link #isBlock()} is false
+ */
+ public boolean isCollidable() {
+ return Bukkit.getUnsafe().isCollidable(this);
+ if (this.isBlock()) {
+ return this.asBlockType().hasCollision();
+ }
+ throw new IllegalArgumentException(this + " isn't a block type");
+ }
// Paper end
/**
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index cbc63144e5eb35799548209f8fbee70d0c20a53d..891204af265ac4ef1f654407421e9962c0ff549b 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -212,5 +212,14 @@ public interface UnsafeValues {
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first)
*/
@org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
+ // Paper end - isCollidable API
+
+ /**
+ * Checks if this material is collidable.
+ *
+ * @param material the material to check
+ * @return true if collidable
+ * @throws IllegalArgumentException if {@link Material#isBlock()} is false
+ */
+ boolean isCollidable(@org.jetbrains.annotations.NotNull Material material);
// Paper end
}
/**
* Do not use for any reason.
*
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index b5fe76a6353816a2d009dfa5921f8ada92984f34..42cc4f2ee960c0abf9c6688aeee4150754612c32 100644
--- a/src/main/java/org/bukkit/block/Block.java
@ -80,3 +66,21 @@ index fd4a9bdcfb6775dfbdb7492e6c9eb90722d2ecdc..e573e70d9e74e444783a7363e6cdac12
+ boolean isCollidable();
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
index d4e824ad18714b951cf161031a9566e6796ab507..61a73e813f7c14c61fac358e96aaaa64c41e560b 100644
--- a/src/main/java/org/bukkit/block/BlockType.java
+++ b/src/main/java/org/bukkit/block/BlockType.java
@@ -3611,4 +3611,13 @@ public interface BlockType extends Keyed, Translatable, net.kyori.adventure.tran
@Override
@NotNull String getTranslationKey();
// Paper end - add Translatable
+
+ // Paper start - hasCollision API
+ /**
+ * Checks if this block type has collision.
+ * <p>
+ * @return false if this block never has collision, true if it <b>might</b> have collision
+ */
+ boolean hasCollision();
+ // Paper end - hasCollision API
}

View File

@ -6,14 +6,15 @@ Subject: [PATCH] Add NamespacedKey biome methods
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 20ddbfdad6856135a4c6a4778f81caee953f0fb4..c49f73355da362abb1c0e52f867dcfad8d4680f3 100644
index 240ac3f658ed24d3980707e146e6dfee6c9b31a0..dad90b98413b57a878f940b8f423bd77e36fd179 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -229,5 +229,32 @@ public interface UnsafeValues {
* @throws IllegalArgumentException if {@link Material#isBlock()} is false
@@ -221,4 +221,33 @@ public interface UnsafeValues {
*/
boolean isCollidable(@org.jetbrains.annotations.NotNull Material material);
@org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
// Paper end
+
+ // Paper start - namespaced key biome methods
+ /**
+ * Gets the {@link NamespacedKey} for the biome at the given location.
+ *
@ -40,5 +41,5 @@ index 20ddbfdad6856135a4c6a4778f81caee953f0fb4..c49f73355da362abb1c0e52f867dcfad
+ * @throws IllegalStateException if no biome by the given key is registered.
+ */
+ void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey);
// Paper end
+ // Paper end - namespaced key biome methods
}

View File

@ -5,16 +5,15 @@ Subject: [PATCH] Fix custom statistic criteria creation
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index c49f73355da362abb1c0e52f867dcfad8d4680f3..289346bcd0ef42cfaf2afc270eeb7525e520ce80 100644
index dad90b98413b57a878f940b8f423bd77e36fd179..f261bd5971003e542e4806c1a989add8e0143466 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -256,5 +256,7 @@ public interface UnsafeValues {
* @throws IllegalStateException if no biome by the given key is registered.
@@ -250,4 +250,6 @@ public interface UnsafeValues {
*/
void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey);
// Paper end - namespaced key biome methods
+
+ String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic);
// Paper end
+ String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); // Paper - fix custom stats criteria creation
}
diff --git a/src/main/java/org/bukkit/scoreboard/Criteria.java b/src/main/java/org/bukkit/scoreboard/Criteria.java
index 7d79d7fadab19bfbefc4797d7e5bbd3e9d733b53..3bc3abaf093d13e22b6ac2ee59ab584c92b4666a 100644

View File

@ -5,13 +5,13 @@ Subject: [PATCH] Add api for spawn egg texture colors
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 289346bcd0ef42cfaf2afc270eeb7525e520ce80..ffb22192e08b9d47ac2667efa0d62a548f14d46b 100644
index f261bd5971003e542e4806c1a989add8e0143466..02d34db5f44ed63c4635077eb2b3cb98ac94b7b2 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -259,4 +259,17 @@ public interface UnsafeValues {
@@ -252,4 +252,17 @@ public interface UnsafeValues {
// Paper end - namespaced key biome methods
String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic);
// Paper end
String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); // Paper - fix custom stats criteria creation
+
+ // Paper start - spawn egg color visibility
+ /**

View File

@ -528,10 +528,10 @@ index 0000000000000000000000000000000000000000..304f978e40e1759bb19704cc5cec3995
+ }
+}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index ffb22192e08b9d47ac2667efa0d62a548f14d46b..6b67c32343876f345459300a4bb6b692412bfc52 100644
index 02d34db5f44ed63c4635077eb2b3cb98ac94b7b2..3f1b48fd65df954e874e6dc6b9093cb12370e2c5 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -272,4 +272,12 @@ public interface UnsafeValues {
@@ -265,4 +265,12 @@ public interface UnsafeValues {
*/
@Nullable org.bukkit.Color getSpawnEggLayerColor(org.bukkit.entity.EntityType entityType, int layer);
// Paper end - spawn egg color visibility

View File

@ -108,10 +108,10 @@ index 0000000000000000000000000000000000000000..1d9bed6691f581529c53b577b26f1d0f
+ }
+}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 6b67c32343876f345459300a4bb6b692412bfc52..0857a65ecbc36e0e4b8a7d0cda52be35f238f660 100644
index 3f1b48fd65df954e874e6dc6b9093cb12370e2c5..0e9ccfee7a03d341e7c4d271f53b4ed168b404ef 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -280,4 +280,6 @@ public interface UnsafeValues {
@@ -273,4 +273,6 @@ public interface UnsafeValues {
@org.jetbrains.annotations.ApiStatus.Internal
io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit.plugin.Plugin> createPluginLifecycleEventManager(final org.bukkit.plugin.java.JavaPlugin plugin, final java.util.function.BooleanSupplier registrationCheck);
// Paper end - lifecycle event API

View File

@ -25,6 +25,22 @@ index f041b5d80bff9c022b007e04ef1558e9116acc6b..a586442422a2b2c06b785af0d261d3e1
+ }
// Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java
index f6ffb81b68e0cf3afebe901a5ba8e305bb94b77a..f2f62667ddf082796011ad7dd025e8855b765c1f 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java
@@ -225,4 +225,11 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
public Material asMaterial() {
return Registry.MATERIAL.get(this.key);
}
+
+ // Paper start - add Translatable
+ @Override
+ public String translationKey() {
+ return this.block.getDescriptionId();
+ }
+ // 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 5ed90ed0461165da02c7a1acae805c12466e38d6..faf0f726453aa957d17b75dfd8de5b40d984e69c 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@ -41,6 +57,22 @@ index 5ed90ed0461165da02c7a1acae805c12466e38d6..faf0f726453aa957d17b75dfd8de5b40
// Paper end
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
index f5bb5802aae64773252c9399df0fbe9de3d1d121..1aa8010e872686f392430ce47214a324d431cada 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
@@ -226,4 +226,11 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han
public Material asMaterial() {
return Registry.MATERIAL.get(this.key);
}
+
+ // Paper start - add Translatable
+ @Override
+ public String translationKey() {
+ return this.item.getDescriptionId();
+ }
+ // Paper end - add Translatable
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
index ebdb19d7ee0460d50c082b0a41b3a6a57a3534ee..b444bd26d6c3def3494d3cc0520e462408272be3 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java

View File

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 4 Nov 2021 11:50:40 -0700
Subject: [PATCH] Add isCollidable methods to various places
Subject: [PATCH] Add hasCollision methods to various places
== AT ==
public net.minecraft.world.level.block.state.BlockBehaviour hasCollision
@ -38,20 +38,19 @@ index 1002123cd0c6f57cecc4e80f5f21cc6ff5886d37..e96023b71845526383288917e8d7c575
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 6bfd5fad899720c853fc4812f50893a6d81f7ea8..3824a02431e3b1d82576937248f2a57f1a0414b0 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -575,6 +575,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier);
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java
index f2f62667ddf082796011ad7dd025e8855b765c1f..5d3ce8c8cb02c5a61f011adbecd10ae041cbb99b 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java
@@ -232,4 +232,11 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
return this.block.getDescriptionId();
}
// Paper end - add Translatable
+
+ // Paper start - hasCollision API
+ @Override
+ public boolean isCollidable(Material material) {
+ Preconditions.checkArgument(material.isBlock(), material + " is not a block");
+ return getBlock(material).hasCollision;
+ public boolean hasCollision() {
+ return this.block.hasCollision;
+ }
// Paper end
@Override
+ // Paper end - hasCollision API
}

View File

@ -6,14 +6,14 @@ Subject: [PATCH] Add NamespacedKey biome methods
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index a2961166695e5fe4c607c82a490ce67c2e1b5fde..77cc32eb8b3e835af229fcb78229bfc09bd0da70 100644
index 7d56cfaa460c1052d60344542c8ea60363894b8d..f5e8ff2a98a2357cb766e69bea982b25f2e2911b 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -607,6 +607,19 @@ public final class CraftMagicNumbers implements UnsafeValues {
Preconditions.checkArgument(material.isBlock(), material + " is not a block");
return getBlock(material).hasCollision;
@@ -603,6 +603,21 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
+
// Paper end
+ // Paper start - namespaced key biome methods
+ @Override
+ public org.bukkit.NamespacedKey getBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z) {
+ org.bukkit.craftbukkit.CraftRegionAccessor cra = (org.bukkit.craftbukkit.CraftRegionAccessor) accessor;
@ -26,6 +26,8 @@ index a2961166695e5fe4c607c82a490ce67c2e1b5fde..77cc32eb8b3e835af229fcb78229bfc0
+ net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeBase = cra.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey)));
+ cra.setBiome(x, y, z, biomeBase);
+ }
// Paper end
+ // Paper end - namespaced key biome methods
+
@Override
public String get(Class<?> aClass, String s) {
if (aClass == Enchantment.class) {

View File

@ -5,19 +5,21 @@ Subject: [PATCH] Fix custom statistic criteria creation
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 77cc32eb8b3e835af229fcb78229bfc09bd0da70..2d51418612e4df40b9536ac72ba0a070d59f32d1 100644
index f5e8ff2a98a2357cb766e69bea982b25f2e2911b..ea48f9317f66305bca0f01c51953b438f6e4833c 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -620,6 +620,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeBase = cra.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey)));
cra.setBiome(x, y, z, biomeBase);
@@ -618,6 +618,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
+
// Paper end - namespaced key biome methods
+ // Paper start - fix custom stats criteria creation
+ @Override
+ public String getStatisticCriteriaKey(org.bukkit.Statistic statistic) {
+ if (statistic.getType() != org.bukkit.Statistic.Type.UNTYPED) return "minecraft.custom:minecraft." + statistic.getKey().getKey();
+ return org.bukkit.craftbukkit.CraftStatistic.getNMSStatistic(statistic).getName();
+ }
// Paper end
+ // Paper end - fix custom stats criteria creation
+
@Override
public String get(Class<?> aClass, String s) {
if (aClass == Enchantment.class) {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add api for spawn egg texture colors
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 34208c749621003ba3ad74894ca25e01469b66f2..0e23219206d94308e0d5d1519d7f80678ffa4f73 100644
index 0542c04bc9c59ff04291f2a45b70a7b43d74e7d5..053c09fa00d08b50aa25614a6310299efffe203a 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -663,6 +663,15 @@ public final class CraftMagicNumbers implements UnsafeValues {
@@ -661,6 +661,15 @@ public final class CraftMagicNumbers implements UnsafeValues {
return CraftRegistry.get(registry, namespacedKey, ApiVersion.CURRENT);
}

View File

@ -707,7 +707,7 @@ index 2e96308696e131f3f013469a395e5ddda2c5d529..65a66e484c1c39c5f41d97db52f31c67
} catch (Throwable e) {
LOGGER.error("Failed to run bootstrapper for %s. This plugin will not be loaded.".formatted(provider.getSource()), e);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d7178155e548eb027e75bb8e7f03d077cae6831e..34242fa907bb87ef78cf96ca81ae224de750956f 100644
index ffb456ef6386eaaca3df3f36666e41f85210f88c..99a06496935489ff641c4db78e147d29466dc05a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1013,6 +1013,11 @@ public final class CraftServer implements Server {
@ -739,10 +739,10 @@ index d96399e9bf1a58db5a4a22e58abb99e7660e0694..66bdac50130f523f9dc4379b103b7a46
+ // Paper end - lifecycle events
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 0e23219206d94308e0d5d1519d7f80678ffa4f73..89e4f53598c14ea2ca2b6678edc97366649d0145 100644
index 053c09fa00d08b50aa25614a6310299efffe203a..b137d4518727bfb4a058abbf33e6cfd3b6e05772 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -672,6 +672,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
@@ -670,6 +670,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
// Paper end - spawn egg color visibility

View File

@ -5,13 +5,13 @@ Subject: [PATCH] ItemStack Tooltip API
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 89e4f53598c14ea2ca2b6678edc97366649d0145..9bd51aeedf2556e714960b081029f48afbc0f3f5 100644
index b137d4518727bfb4a058abbf33e6cfd3b6e05772..5572ecea5df864db291eff182969f0367fb7c5f5 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -647,6 +647,20 @@ public final class CraftMagicNumbers implements UnsafeValues {
return org.bukkit.craftbukkit.CraftStatistic.getNMSStatistic(statistic).getName();
@@ -646,6 +646,21 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
// Paper end
// Paper end - fix custom stats criteria creation
+ // Paper start - expose itemstack tooltip lines
+ @Override
+ public java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(final ItemStack itemStack, final io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final org.bukkit.entity.Player player) {
@ -26,6 +26,7 @@ index 89e4f53598c14ea2ca2b6678edc97366649d0145..9bd51aeedf2556e714960b081029f48a
+ return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList();
+ }
+ // Paper end - expose itemstack tooltip lines
+
@Override
public String get(Class<?> aClass, String s) {
if (aClass == Enchantment.class) {