13
0
geforkt von Mirrors/Paper

Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11197)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
2ec53f49 PR-1050: Fix empty result check for Complex Recipes
10671012 PR-1044: Add CrafterCraftEvent
4d87ffe0 Use correct method in JavaDoc
ae5e5817 SPIGOT-7850: Add API for Bogged shear state
46b6d445 SPIGOT-7837: Support data pack banner patterns
d5d0cefc Fix JavaDoc error
b3c2b83d PR-1036: Add API for InventoryView derivatives
1fe2c75a SPIGOT-7809: Add ShieldMeta

CraftBukkit Changes:
8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization
8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta
759061b93 SPIGOT-7855: Fire does not spread or burn blocks
00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0
7501e2e04 PR-1450: Add CrafterCraftEvent
8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel
d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled
682a678c8 SPIGOT-7850: Add API for Bogged shear state
fccf5243a SPIGOT-7837: Support data pack banner patterns
9c3bd4390 PR-1431: Add API for InventoryView derivatives
0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null
2c5474952 Don't rely on tags for CraftItemMetas
20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs
76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent
e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters
894682e2d SPIGOT-7839: Remove redundant Java version checks
2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours

Spigot Changes:
fb8fb722 Rebuild patches
34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
Dieser Commit ist enthalten in:
Bjarne Koll 2024-08-09 22:05:50 +02:00
Ursprung 35fd8fb960
Commit b819030e31
33 geänderte Dateien mit 555 neuen und 416 gelöschten Zeilen

Datei anzeigen

@ -1,97 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ploppyperson <nathat890@outlook.com>
Date: Thu, 18 Jul 2024 16:37:58 +0200
Subject: [PATCH] Add CrafterCraftEvent
Ports the currently proposed CrafterCraftEvent
from upstream.
The type is experimental to account for spigot
potentially changing some api contracts, however
the event is required for a stable release and
waiting on spigot's PR queue is not an option.
See: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/1044/overview
diff --git a/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java b/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java
@@ -0,0 +0,0 @@
+package org.bukkit.event.block;
+
+import org.bukkit.block.Block;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.CraftingRecipe;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Event called when a Crafter is about to craft an item
+ * @apiNote Currently still experimental as it is ported from an open, not merged, spigot PR.
+ * The event was pulled to allow protection plugins and the likes to properly manage crafters.
+ * The type remains experimental as upstream *may* change the event before pulling it, resulting in a breaking change.
+ */
+@org.jetbrains.annotations.ApiStatus.Experimental
+public class CrafterCraftEvent extends BlockEvent implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private ItemStack result;
+ private final CraftingRecipe recipe;
+
+ @org.jetbrains.annotations.ApiStatus.Internal // Paper - internal constructor.
+ public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) {
+ super(theBlock);
+ this.result = result;
+ this.recipe = recipe;
+ }
+
+ /**
+ * Gets the result for the craft
+ * @return the result for the craft
+ */
+ @NotNull
+ public ItemStack getResult() {
+ return result.clone();
+ }
+
+ /**
+ * Sets the result of the craft
+ * @param result the result of the craft
+ */
+ public void setResult(@NotNull ItemStack result) {
+ this.result = result.clone();
+ }
+
+ /**
+ * The recipe that was used to craft this item
+ * @return the recipe that was used to craft this item
+ */
+ @NotNull
+ public CraftingRecipe getRecipe() {
+ return recipe;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

Datei anzeigen

@ -106,10 +106,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- private static final HandlerList handlers = new HandlerList();
+ // Paper - move HandlerList to PrepareInventoryResultEvent
public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
public PrepareAnvilEvent(@NotNull AnvilView inventory, @Nullable ItemStack result) {
super(inventory, result);
@@ -0,0 +0,0 @@ public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
super.setResult(result);
return (AnvilView) super.getView();
}
- @NotNull

Datei anzeigen

@ -209,6 +209,18 @@ diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/R
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -0,0 +0,0 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* Server banner patterns.
*
* @see PatternType
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#BANNER_PATTERN}
*/
- Registry<PatternType> BANNER_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(PatternType.class), "No registry present for Pattern Type. This is a bug.");
+ @Deprecated(since = "1.21") // Paper
+ Registry<PatternType> BANNER_PATTERN = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(PatternType.class), "No registry present for PatternType. This is a bug."); // Paper
/**
* Server biomes.
*
@@ -0,0 +0,0 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @apiNote BlockType is not ready for public usage yet
*/

Datei anzeigen

@ -61,8 +61,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
* Represents a Bogged Skeleton.
*/
@ApiStatus.Experimental
-public interface Bogged extends AbstractSkeleton {
+public interface Bogged extends AbstractSkeleton, io.papermc.paper.entity.Shearable { // Paper - Shear API
-public interface Bogged extends AbstractSkeleton, Shearable {
+public interface Bogged extends AbstractSkeleton, Shearable, io.papermc.paper.entity.Shearable { // Paper - Shear API
}
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -77,6 +77,41 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
* Checks for the presence of custom potion effects to be applied to the
diff --git a/src/main/java/org/bukkit/entity/Shearable.java b/src/main/java/org/bukkit/entity/Shearable.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Shearable.java
+++ b/src/main/java/org/bukkit/entity/Shearable.java
@@ -0,0 +0,0 @@ package org.bukkit.entity;
/**
* Represents an entity which can be shorn with shears.
+ * @deprecated Spigots shearable API miserably fails at capturing all entities that may be sheared by a player, like
+ * mushroom cows which, once sheared, convert into normal cows. For such entities, methods like
+ * {@link #setSheared(boolean)} or {@link #isSheared()} make no sense, making this API and interface dead API from
+ * the get-go.
*/
+@Deprecated(forRemoval = true, since = "1.21")
public interface Shearable {
/**
* Gets whether the entity is in its sheared state.
*
* @return Whether the entity is sheared.
+ * @deprecated Use {@link io.papermc.paper.entity.Shearable#readyToBeSheared()} instead.
*/
+ @Deprecated(forRemoval = true, since = "1.21")
boolean isSheared();
/**
* Sets whether the entity is in its sheared state.
*
* @param flag Whether to shear the entity
+ * @deprecated Use {@link io.papermc.paper.entity.Shearable#shear()} instead if applicable.
+ * Some entities cannot be "unsheared".
*/
+ @Deprecated(forRemoval = true, since = "1.21")
void setSheared(boolean flag);
}
diff --git a/src/main/java/org/bukkit/entity/Sheep.java b/src/main/java/org/bukkit/entity/Sheep.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Sheep.java
@ -85,11 +120,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
* Represents a Sheep.
*/
-public interface Sheep extends Animals, Colorable {
+public interface Sheep extends Animals, Colorable, io.papermc.paper.entity.Shearable { // Paper - Shear API
/**
* @return Whether the sheep is sheared.
-public interface Sheep extends Animals, Colorable, Shearable {
+public interface Sheep extends Animals, Colorable, Shearable, io.papermc.paper.entity.Shearable { // Paper - Shear API
}
diff --git a/src/main/java/org/bukkit/entity/Snowman.java b/src/main/java/org/bukkit/entity/Snowman.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Snowman.java

Datei anzeigen

@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/inventory/AnvilInventory.java
+++ b/src/main/java/org/bukkit/inventory/AnvilInventory.java
@@ -0,0 +0,0 @@ public interface AnvilInventory extends Inventory {
* @param levels the maximum experience cost
*/
@Deprecated(forRemoval = true, since = "1.21")
void setMaximumRepairCost(int levels);
+
+ // Paper start

Datei anzeigen

@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ShapedRecipe extends CraftingRecipe {
@Deprecated
public ShapedRecipe(@NotNull ItemStack result) {
super(NamespacedKey.randomKey(), result);
this(NamespacedKey.randomKey(), result);
+ new Throwable("Warning: A plugin is creating a recipe using a Deprecated method. This will cause you to receive warnings stating 'Tried to load unrecognized recipe: bukkit:<ID>'. Please ask the author to give their recipe a static key using NamespacedKey.").printStackTrace(); // Paper
}
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ShapelessRecipe extends CraftingRecipe {
@Deprecated
public ShapelessRecipe(@NotNull ItemStack result) {
super(NamespacedKey.randomKey(), result);
this(NamespacedKey.randomKey(), result);
+ new Throwable("Warning: A plugin is creating a recipe using a Deprecated method. This will cause you to receive warnings stating 'Tried to load unrecognized recipe: bukkit:<ID>'. Please ask the author to give their recipe a static key using NamespacedKey.").printStackTrace(); // Paper
}

Datei anzeigen

@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
* Represents a Bogged Skeleton.
*/
-@ApiStatus.Experimental
public interface Bogged extends AbstractSkeleton, io.papermc.paper.entity.Shearable { // Paper - Shear API
public interface Bogged extends AbstractSkeleton, Shearable, io.papermc.paper.entity.Shearable { // Paper - Shear API
}
diff --git a/src/main/java/org/bukkit/entity/Breeze.java b/src/main/java/org/bukkit/entity/Breeze.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

Datei anzeigen

@ -1067,6 +1067,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public class CampfireStartEvent extends InventoryBlockStartEvent {
private static final HandlerList handlers = new HandlerList();
diff --git a/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java b/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java
+++ b/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java
@@ -0,0 +0,0 @@ public class CrafterCraftEvent extends BlockEvent implements Cancellable {
private ItemStack result;
private boolean cancelled;
+ @org.jetbrains.annotations.ApiStatus.Internal // Paper - fix upstream annotation mistakes
public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) {
super(theBlock);
this.result = result;
diff --git a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java b/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java
@ -1075,8 +1087,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private boolean cancelled;
private final Player enchanter;
- public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, @NotNull final EnchantmentOffer[] offers, final int bonus) {
+ public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, @org.jetbrains.annotations.Nullable final EnchantmentOffer @NotNull [] offers, final int bonus) { // Paper - offers can contain null values
- public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull EnchantmentView view, @NotNull final Block table, @NotNull final ItemStack item, @NotNull final EnchantmentOffer[] offers, final int bonus) {
+ public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull EnchantmentView view, @NotNull final Block table, @NotNull final ItemStack item, @org.jetbrains.annotations.Nullable final EnchantmentOffer @NotNull [] offers, final int bonus) { // Paper - offers can contain null values
super(view);
this.enchanter = enchanter;
this.table = table;

Datei anzeigen

@ -44,14 +44,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/inventory/CraftingRecipe.java
+++ b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
@@ -0,0 +0,0 @@ public abstract class CraftingRecipe implements Recipe, Keyed {
protected CraftingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) {
Preconditions.checkArgument(key != null, "key cannot be null");
@ApiStatus.Internal
@NotNull
protected static ItemStack checkResult(@NotNull ItemStack result) {
- Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result.");
+ Preconditions.checkArgument(!result.isEmpty(), "Recipe cannot have an empty result."); // Paper
this.key = key;
this.output = new ItemStack(result);
return result;
}
}
diff --git a/src/main/java/org/bukkit/inventory/EmptyRecipeChoice.java b/src/main/java/org/bukkit/inventory/EmptyRecipeChoice.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

Datei anzeigen

@ -1022,7 +1022,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
@NotNull
@Override
public HandlerList getHandlers() {
public AnvilView getView() {
diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
@ -1443,7 +1443,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
* @deprecated Recipes must have keys. Use {@link #ShapedRecipe(NamespacedKey, ItemStack)}
* instead.
@@ -0,0 +0,0 @@ public class ShapedRecipe extends CraftingRecipe {
* @param result The item you want the recipe to create.
* @exception IllegalArgumentException if the {@code result} is an empty item (AIR)
* @see ShapedRecipe#shape(String...)
* @see ShapedRecipe#setIngredient(char, Material)
- * @see ShapedRecipe#setIngredient(char, Material, int)
@ -1456,8 +1456,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
+++ b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
@@ -0,0 +0,0 @@ public class ShapelessRecipe extends CraftingRecipe {
* @param key the unique recipe key
* @param result The item you want the recipe to create.
* @exception IllegalArgumentException if the {@code result} is an empty item (AIR)
* @see ShapelessRecipe#addIngredient(Material)
- * @see ShapelessRecipe#addIngredient(MaterialData)
- * @see ShapelessRecipe#addIngredient(Material,int)
@ -1467,7 +1467,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @see ShapelessRecipe#addIngredient(RecipeChoice)
*/
public ShapelessRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) {
super(key, result);
super(key, checkResult(result));
@@ -0,0 +0,0 @@ public class ShapelessRecipe extends CraftingRecipe {
/**

Datei anzeigen

@ -19,6 +19,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.flicker = flicker;
this.trail = trail;
this.colors = colors;
diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/inventory/ItemType.java
+++ b/src/main/java/org/bukkit/inventory/ItemType.java
@@ -0,0 +0,0 @@ import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.inventory.meta.MusicInstrumentMeta;
import org.bukkit.inventory.meta.OminousBottleMeta;
import org.bukkit.inventory.meta.PotionMeta;
+import org.bukkit.inventory.meta.ShieldMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.inventory.meta.SuspiciousStewMeta;
@@ -0,0 +0,0 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans
/**
* ItemMeta: {@link BlockStateMeta}
*/
- ItemType.Typed<BlockStateMeta> SHIELD = getItemType("shield");
+ ItemType.Typed<ShieldMeta> SHIELD = getItemType("shield"); // Paper - update shield to its new meta
ItemType.Typed<ItemMeta> TOTEM_OF_UNDYING = getItemType("totem_of_undying");
ItemType.Typed<ItemMeta> SHULKER_SHELL = getItemType("shulker_shell");
ItemType.Typed<ItemMeta> IRON_NUGGET = getItemType("iron_nugget");
diff --git a/src/main/java/org/bukkit/inventory/meta/Damageable.java b/src/main/java/org/bukkit/inventory/meta/Damageable.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/inventory/meta/Damageable.java

Datei anzeigen

@ -131,9 +131,9 @@ diff --git a/src/main/java/org/bukkit/block/banner/PatternType.java b/src/main/j
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/block/banner/PatternType.java
+++ b/src/main/java/org/bukkit/block/banner/PatternType.java
@@ -0,0 +0,0 @@ public enum PatternType implements Keyed {
this.key = NamespacedKey.minecraft(key);
}
@@ -0,0 +0,0 @@ public interface PatternType extends OldEnum<PatternType>, Keyed {
PatternType FLOW = getType("flow");
PatternType GUSTER = getType("guster");
+ // Paper start - deprecate getKey
+ /**
@ -144,7 +144,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - deprecate getKey
@Override
@NotNull
public NamespacedKey getKey() {
public NamespacedKey getKey();
diff --git a/src/main/java/org/bukkit/generator/structure/Structure.java b/src/main/java/org/bukkit/generator/structure/Structure.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/generator/structure/Structure.java

Datei anzeigen

@ -1,27 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <git@lynxplay.dev>
Date: Fri, 19 Jul 2024 19:09:21 +0200
Subject: [PATCH] Move CraftComplexRecipe to extend CraftingRecipe
A craft complex recipe wraps a CustomRecipe, which itself is a
CraftingRecipe.
As such, this complex recipe should also be a crafting recipe.
diff --git a/src/main/java/org/bukkit/inventory/CraftingRecipe.java b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/inventory/CraftingRecipe.java
+++ b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
* Represents a shaped or shapeless crafting recipe.
*/
public abstract class CraftingRecipe implements Recipe, Keyed {
- private final NamespacedKey key;
- private final ItemStack output;
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - start
+ protected NamespacedKey key;
+ protected ItemStack output;
+ protected CraftingRecipe() {}
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - end
private String group = "";
private CraftingBookCategory category = CraftingBookCategory.MISC;

Datei anzeigen

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.destroystokyo.paper.inventory.meta.ArmorStandMeta;
import java.util.function.BiFunction;
import java.util.function.Function;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.BannerItem;
@@ -0,0 +0,0 @@ public final class CraftItemMetas {
item -> new CraftMetaSpawnEgg(item.getComponentsPatch()),
(type, meta) -> meta instanceof CraftMetaSpawnEgg spawnEgg ? spawnEgg : new CraftMetaSpawnEgg(meta));

Datei anzeigen

@ -22,3 +22,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public BlockState getBlockState() {
return (this.blockEntityTag != null) ? this.blockEntityTag.copy() : CraftMetaBlockState.getBlockState(this.material, null);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
this.banner = (Banner) blockState;
}
+ // Paper start - add method to clear block state
+ @Override
+ public void clearBlockState() {
+ this.banner = null;
+ }
+ // Paper end - add method to clear block state
+
private static Banner getBlockState(DyeColor color) {
BlockPos pos = BlockPos.ZERO;
Material stateMaterial = CraftMetaShield.shieldToBannerHack(color);

Datei anzeigen

@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ploppyperson <nathat890@outlook.com>
Date: Thu, 18 Jul 2024 16:38:48 +0200
Subject: [PATCH] Add CrafterCraftEvent
While not a one-to-one copy from the proposed commit upstream,
the patch calls the preemtively pulled CrafterCraftEvent.
See: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1450/overview
diff --git a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java
@@ -0,0 +0,0 @@ public class CrafterBlock extends BaseEntityBlock {
} else {
RecipeHolder<CraftingRecipe> recipeHolder = optional.get();
ItemStack itemStack = recipeHolder.value().assemble(var11, world.registryAccess());
+ // Paper start - call CrafterCraftEvent
+ final org.bukkit.event.block.CrafterCraftEvent event = new org.bukkit.event.block.CrafterCraftEvent(
+ org.bukkit.craftbukkit.block.CraftBlock.at(world, pos),
+ (org.bukkit.inventory.CraftingRecipe) recipeHolder.toBukkitRecipe(),
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack)
+ );
+ if (!event.callEvent()) return;
+
+ itemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getResult());
+ // Paper end - call CrafterCraftEvent
if (itemStack.isEmpty()) {
world.levelEvent(1050, pos, 0);
} else {

Datei anzeigen

@ -100,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class CraftEventFactory {
}
public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) {
public static PrepareAnvilEvent callPrepareAnvilEvent(AnvilView view, ItemStack item) {
+ // Paper start - Add PrepareResultEvent
+ if (true) {
+ view.getTopInventory().setItem(net.minecraft.world.inventory.AnvilMenu.RESULT_SLOT, CraftItemStack.asCraftMirror(item));
@ -145,8 +145,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ InventoryView view = container.getBukkitView();
+ org.bukkit.inventory.ItemStack origItem = view.getTopInventory().getItem(resultSlot);
+ CraftItemStack result = origItem != null ? CraftItemStack.asCraftCopy(origItem) : null;
+ if (view.getTopInventory() instanceof org.bukkit.inventory.AnvilInventory) {
+ event = new PrepareAnvilEvent(view, result);
+ if (view.getTopInventory() instanceof org.bukkit.inventory.AnvilInventory && view instanceof AnvilView anvilView) {
+ event = new PrepareAnvilEvent(anvilView, result);
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.GrindstoneInventory) {
+ event = new PrepareGrindstoneEvent(view, result);
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.SmithingInventory) {

Datei anzeigen

@ -10,9 +10,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ public class CraftEventFactory {
return CraftItemStack.asNMSCopy(bitem);
Bukkit.getPluginManager().callEvent(crafterCraftEvent);
return crafterCraftEvent;
}
+ // Paper start
+ @Deprecated
+ public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, EntityHitResult position) {
@ -23,10 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return event;
+ }
+ // Paper end
+
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) {
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity();
ProjectileLaunchEvent event = new ProjectileLaunchEvent(bukkitEntity);
@@ -0,0 +0,0 @@ public class CraftEventFactory {
if (position.getType() == HitResult.Type.ENTITY) {
hitEntity = ((EntityHitResult) position).getEntity().getBukkitEntity();

Datei anzeigen

@ -35,10 +35,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.Keyed;
+import org.bukkit.MusicInstrument;
+import org.bukkit.block.BlockType;
+import org.bukkit.block.banner.PatternType;
+import org.bukkit.craftbukkit.CraftGameEvent;
+import org.bukkit.craftbukkit.CraftJukeboxSong;
+import org.bukkit.craftbukkit.CraftMusicInstrument;
+import org.bukkit.craftbukkit.block.CraftBlockType;
+import org.bukkit.craftbukkit.block.banner.CraftPatternType;
+import org.bukkit.craftbukkit.damage.CraftDamageType;
+import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
+import org.bukkit.craftbukkit.entity.CraftCat;
@ -102,12 +104,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ entry(Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant::new).delayed(),
+ entry(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(),
+ entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(),
+ entry(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, PatternType.class, CraftPatternType::new).delayed(),
+
+ // api-only
+ apiOnly(Registries.BIOME, RegistryKey.BIOME, () -> org.bukkit.Registry.BIOME),
+ apiOnly(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, () -> org.bukkit.Registry.ART),
+ apiOnly(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, () -> org.bukkit.Registry.ATTRIBUTE),
+ apiOnly(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, () -> org.bukkit.Registry.BANNER_PATTERN),
+ apiOnly(Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE, () -> org.bukkit.Registry.ENTITY_TYPE),
+ apiOnly(Registries.PARTICLE_TYPE, RegistryKey.PARTICLE_TYPE, () -> org.bukkit.Registry.PARTICLE_TYPE),
+ apiOnly(Registries.POTION, RegistryKey.POTION, () -> org.bukkit.Registry.POTION),
@ -796,6 +798,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (bukkitClass == MapCursor.Type.class) {
- return new CraftRegistry<>(MapCursor.Type.class, registryHolder.registryOrThrow(Registries.MAP_DECORATION_TYPE), CraftMapCursor.CraftType::new, FieldRename.NONE);
- }
- if (bukkitClass == PatternType.class) {
- return new CraftRegistry<>(PatternType.class, registryHolder.registryOrThrow(Registries.BANNER_PATTERN), CraftPatternType::new, FieldRename.NONE);
- }
-
- return null;
- }
@ -1191,6 +1196,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- register(Frog.Variant.class, Registries.FROG_VARIANT, CraftFrog.CraftVariant.class, FrogVariant.class);
- register(Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class);
- register(MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class);
- register(PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class);
-
+ // Order: RegistryKey, Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class
+ register(RegistryKey.ENCHANTMENT, Enchantment.class, Registries.ENCHANTMENT, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class);
+ register(RegistryKey.GAME_EVENT, GameEvent.class, Registries.GAME_EVENT, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class);
@ -1210,7 +1217,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ register(RegistryKey.FROG_VARIANT, Frog.Variant.class, Registries.FROG_VARIANT, CraftFrog.CraftVariant.class, FrogVariant.class);
+ register(RegistryKey.CAT_VARIANT, Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class);
+ register(RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class);
+ register(RegistryKey.BANNER_PATTERN, PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class);
}
- private static void register(Class bukkit, ResourceKey registry, Class craft, Class minecraft) {

Datei anzeigen

@ -13,16 +13,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
+ world.scheduleTick(pos, this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
+ world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
if (world.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
if (!state.canSurvive(world, pos)) {
this.fireExtinguished(world, pos); // CraftBukkit - invalid place location
@@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock {
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
super.onPlace(state, world, pos, oldState, notify, context);
// Paper end - UseOnContext param
- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
+ world.scheduleTick(pos, this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
protected void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext context) {
super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, context);
// CraftBukkit end
- world.scheduleTick(blockposition, (Block) this, FireBlock.getFireTickDelay(world.random));
+ world.scheduleTick(blockposition, (Block) this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
}
- private static int getFireTickDelay(RandomSource random) {

Datei anzeigen

@ -33,8 +33,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- entry(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(),
+ writable(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new, PaperEnchantmentRegistryEntry.PaperBuilder::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(),
entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(),
entry(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, PatternType.class, CraftPatternType::new).delayed(),
// api-only
diff --git a/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java b/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

Datei anzeigen

@ -4806,7 +4806,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.j
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java
@@ -0,0 +0,0 @@ public class CraftInventoryView extends CraftAbstractInventoryView {
@@ -0,0 +0,0 @@ public class CraftInventoryView<T extends AbstractContainerMenu> extends CraftAb
return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem());
}

Datei anzeigen

@ -143,6 +143,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
});
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
@@ -0,0 +0,0 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.configuration.serialization.DelegateDeserialization;
+import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.block.CraftBlockStates;
import org.bukkit.craftbukkit.block.banner.CraftPatternType;
import org.bukkit.inventory.meta.BlockStateMeta;
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
for (int i = 0; i < Math.min(patterns.size(), 20); i++) {
BannerPatternLayers.Layer p = patterns.get(i);
DyeColor color = DyeColor.getByWoolData((byte) p.color().getId());
- PatternType pattern = CraftPatternType.minecraftHolderToBukkit(p.pattern());
+ PatternType pattern = CraftRegistry.unwrapAndConvertHolder(io.papermc.paper.registry.RegistryKey.BANNER_PATTERN, p.pattern()).orElse(null); // Paper - fix upstream not being correct
if (color != null && pattern != null) {
this.addPattern(new Pattern(color, pattern));
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java

Datei anzeigen

@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.blockEntityTag = this.blockEntityTag != null ? this.blockEntityTag : CustomData.EMPTY;
+ }
+ private Material materialForBlockEntityType() {
+ return (this.material != Material.SHIELD) ? this.material : CraftMetaBlockState.shieldToBannerHack();
+ return this.material;
+ }
+ // Paper end
private CompoundTag internalTag;
@ -263,17 +263,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
} else {
this.material = Material.AIR;
}
- this.blockEntityTag = CraftMetaBlockState.getBlockState(this.material, this.internalTag);
+ // Paper start
+ if (this.internalTag != null) { // legacy
+ this.setBlockState(CraftMetaBlockState.getBlockState(this.material, this.internalTag));
+ }
this.internalTag = null;
if (this.internalTag != null) {
- this.blockEntityTag = CraftMetaBlockState.getBlockState(this.material, this.internalTag);
+ this.setBlockState(CraftMetaBlockState.getBlockState(this.material, this.internalTag)); // Paper - general item meta fixes - pass through setter
this.internalTag = null;
}
}
@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
void applyToItem(CraftMetaItem.Applicator tag) {
super.applyToItem(tag);
@ -431,7 +428,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static CraftBlockEntityState<?> getBlockState(Material material, CompoundTag blockEntityTag) {
@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
Class<?> blockStateType = CraftBlockStates.getBlockStateType(stateMaterial);
Preconditions.checkArgument(blockStateType == blockState.getClass() && blockState instanceof CraftBlockEntityState, "Invalid blockState for " + this.material);
Preconditions.checkArgument(blockStateType == blockState.getClass() && blockState instanceof CraftBlockEntityState, "Invalid blockState for %s", this.material);
- this.blockEntityTag = (CraftBlockEntityState<?>) blockState;
+ // Paper start - when a new BlockState is set, the components from that block entity
@ -453,7 +450,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
private static Material shieldToBannerHack() {
private static Material shieldToBannerHack(CompoundTag tag) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@ -1390,6 +1387,306 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
static final ItemMetaKeyType<net.minecraft.world.item.DyeColor> BASE_COLOR = new ItemMetaKeyType<>(DataComponents.BASE_COLOR, "Base", "base-color");
- private Banner banner;
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ private @org.jetbrains.annotations.Nullable List<Pattern> patterns;
+ private @org.jetbrains.annotations.Nullable DyeColor baseColor;
+
+ // An empty pattern list is the same as the default on the Shield item, and will hence not be present in the data components of the stack.
+ private boolean hasPatterns() {
+ return this.patterns != null && !this.patterns.isEmpty();
+ }
+ // Paper end - general item meta fixes - decoupled base colour and patterns
CraftMetaShield(CraftMetaItem meta) {
super(meta);
if (meta instanceof CraftMetaShield craftMetaShield) {
- if (craftMetaShield.banner != null) {
- this.banner = (Banner) craftMetaShield.banner.copy();
- }
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ if (craftMetaShield.patterns != null) this.patterns = new ArrayList<>(craftMetaShield.getPatterns());
+ if (craftMetaShield.baseColor != null) this.baseColor = craftMetaShield.baseColor;
+ // Paper end - general item meta fixes - decoupled base colour and patterns
} else if (meta instanceof CraftMetaBlockState state && state.hasBlockState() && state.getBlockState() instanceof Banner banner) {
- this.banner = (Banner) banner.copy();
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ this.patterns = banner.getPatterns();
+ this.baseColor = banner.getBaseColor();
+ // Paper end - general item meta fixes - decoupled base colour and patterns
}
}
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
super(tag, extraHandledDcts); // Paper - improve checking handled tags in item meta
getOrEmpty(tag, CraftMetaShield.BASE_COLOR).ifPresent((color) -> {
- this.banner = CraftMetaShield.getBlockState(DyeColor.getByWoolData((byte) color.getId()));
+ this.baseColor = DyeColor.getByWoolData((byte) color.getId()); // Paper - general item meta fixes - decoupled base colour and patterns
});
getOrEmpty(tag, CraftMetaBanner.PATTERNS).ifPresent((entityTag) -> {
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
String baseColor = SerializableMeta.getString(map, CraftMetaShield.BASE_COLOR.BUKKIT, true);
if (baseColor != null) {
- this.banner = CraftMetaShield.getBlockState(DyeColor.valueOf(baseColor));
+ this.baseColor = DyeColor.valueOf(baseColor); // Paper - general item meta fixes - decoupled base colour and patterns
}
Iterable<?> rawPatternList = SerializableMeta.getObject(Iterable.class, map, CraftMetaBanner.PATTERNS.BUKKIT, true);
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
void applyToItem(CraftMetaItem.Applicator tag) {
super.applyToItem(tag);
- if (this.banner != null) {
- tag.put(CraftMetaShield.BASE_COLOR, net.minecraft.world.item.DyeColor.byId(this.banner.getBaseColor().getWoolData()));
-
- if (this.banner.numberOfPatterns() > 0) {
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ if (this.baseColor != null) tag.put(CraftMetaShield.BASE_COLOR, net.minecraft.world.item.DyeColor.byId(this.baseColor.getWoolData()));
+ if (this.patterns != null && !this.patterns.isEmpty()) {
+ {
+ // Paper end - general item meta fixes - decoupled base colour and patterns
List<BannerPatternLayers.Layer> newPatterns = new ArrayList<>();
- for (Pattern p : this.banner.getPatterns()) {
+ for (Pattern p : this.patterns) { // Paper - general item meta fixes - decoupled base colour and patterns
newPatterns.add(new BannerPatternLayers.Layer(CraftPatternType.bukkitToMinecraftHolder(p.getPattern()), net.minecraft.world.item.DyeColor.byId(p.getColor().getWoolData())));
}
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
@Override
public List<Pattern> getPatterns() {
- if (this.banner == null) {
+ if (this.patterns == null) { // Paper - general item meta fixes - decoupled base colour and patterns
return new ArrayList<>();
}
- return this.banner.getPatterns();
+ return new ArrayList<>(this.patterns); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public void setPatterns(List<Pattern> patterns) {
- if (this.banner == null) {
- if (patterns.isEmpty()) {
- return;
- }
-
- this.banner = CraftMetaShield.getBlockState(null);
- }
-
- this.banner.setPatterns(patterns);
+ this.patterns = new ArrayList<>(patterns); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public void addPattern(Pattern pattern) {
- if (this.banner == null) {
- this.banner = CraftMetaShield.getBlockState(null);
- }
-
- this.banner.addPattern(pattern);
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ if (this.patterns == null) this.patterns = new ArrayList<>();
+ this.patterns.add(pattern);
+ // Paper end - general item meta fixes - decoupled base colour and patterns
}
@Override
public Pattern getPattern(int i) {
- if (this.banner == null) {
+ if (this.patterns == null) { // Paper - general item meta fixes - decoupled base colour and patterns
throw new IndexOutOfBoundsException(i);
}
- return this.banner.getPattern(i);
+ return this.patterns.get(i); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public Pattern removePattern(int i) {
- if (this.banner == null) {
+ if (this.patterns == null) { // Paper - general item meta fixes - decoupled base colour and patterns
throw new IndexOutOfBoundsException(i);
}
- return this.banner.removePattern(i);
+ return this.patterns.remove(i); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public void setPattern(int i, Pattern pattern) {
- if (this.banner == null) {
+ if (this.patterns == null) { // Paper - general item meta fixes - decoupled base colour and patterns
throw new IndexOutOfBoundsException(i);
}
- this.banner.setPattern(i, pattern);
+ this.patterns.set(i, pattern); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public int numberOfPatterns() {
- if (this.banner == null) {
+ if (this.patterns == null) { // Paper - general item meta fixes - decoupled base colour and patterns
return 0;
}
- return this.banner.numberOfPatterns();
+ return this.patterns.size(); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public DyeColor getBaseColor() {
- if (this.banner == null) {
- return null;
- }
-
- return this.banner.getBaseColor();
+ return this.baseColor; // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public void setBaseColor(DyeColor baseColor) {
- if (baseColor == null) {
- if (this.banner.numberOfPatterns() > 0) {
- this.banner.setBaseColor(DyeColor.WHITE);
- } else {
- this.banner = null;
- }
- } else {
- if (this.banner == null) {
- this.banner = CraftMetaShield.getBlockState(baseColor);
- }
-
- this.banner.setBaseColor(baseColor);
- }
+ this.baseColor = baseColor; // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
super.serialize(builder);
- if (this.banner != null) {
- builder.put(CraftMetaShield.BASE_COLOR.BUKKIT, this.banner.getBaseColor().toString());
-
- if (this.banner.numberOfPatterns() > 0) {
- builder.put(CraftMetaBanner.PATTERNS.BUKKIT, this.banner.getPatterns());
- }
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ if (this.baseColor != null) {
+ builder.put(CraftMetaShield.BASE_COLOR.BUKKIT, this.baseColor.toString());
+ }
+ if (hasPatterns()) {
+ builder.put(CraftMetaBanner.PATTERNS.BUKKIT, this.patterns);
}
+ // Paper end - general item meta fixes - decoupled base colour and patterns
return builder;
}
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
int applyHash() {
final int original;
int hash = original = super.applyHash();
- if (this.banner != null) {
- hash = 61 * hash + this.banner.hashCode();
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ if (this.baseColor != null) {
+ hash = 61 * hash + this.baseColor.hashCode();
+ }
+ if (hasPatterns()) {
+ hash = 61 * hash + this.patterns.hashCode();
+ // Paper end - general item meta fixes - decoupled base colour and patterns
}
return original != hash ? CraftMetaShield.class.hashCode() ^ hash : hash;
}
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
return false;
}
if (meta instanceof CraftMetaShield that) {
- return Objects.equal(this.banner, that.banner);
+ return Objects.equal(this.baseColor, that.baseColor) && Objects.equal(this.hasPatterns(), that.hasPatterns()); // Paper - general item meta fixes - decoupled base colour and patterns
}
return true;
}
@Override
boolean notUncommon(CraftMetaItem meta) {
- return super.notUncommon(meta) && (meta instanceof CraftMetaShield || this.banner == null);
+ return super.notUncommon(meta) && (meta instanceof CraftMetaShield || (this.baseColor == null && !hasPatterns())); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
boolean isEmpty() {
- return super.isEmpty() && this.banner == null;
+ return super.isEmpty() && this.baseColor == null && !hasPatterns(); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public boolean hasBlockState() {
- return this.banner != null;
+ return this.baseColor != null || hasPatterns(); // Paper - general item meta fixes - decoupled base colour and patterns
}
@Override
public BlockState getBlockState() {
- return (this.banner != null) ? this.banner.copy() : CraftMetaShield.getBlockState(null);
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ final Banner banner = CraftMetaShield.getBlockState(this.baseColor);
+ if (this.patterns != null) banner.setPatterns(this.patterns);
+ return banner;
+ // Paper end - general item meta fixes - decoupled base colour and patterns
}
@Override
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
Preconditions.checkArgument(blockState != null, "blockState must not be null");
Preconditions.checkArgument(blockState instanceof Banner, "Invalid blockState");
- this.banner = (Banner) blockState;
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ final Banner banner = (Banner) blockState;
+ this.baseColor = banner.getBaseColor();
+ this.patterns = banner.getPatterns();
+ // Paper end - general item meta fixes - decoupled base colour and patterns
}
// Paper start - add method to clear block state
@Override
public void clearBlockState() {
- this.banner = null;
+ this.baseColor = null;
+ this.patterns = null;
}
// Paper end - add method to clear block state
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
@Override
public CraftMetaShield clone() {
CraftMetaShield meta = (CraftMetaShield) super.clone();
- if (this.banner != null) {
- meta.banner = (Banner) this.banner.copy();
- }
+ // Paper start - general item meta fixes - decoupled base colour and patterns
+ meta.baseColor = this.baseColor;
+ meta.patterns = this.patterns == null ? null : new ArrayList<>(this.patterns);
+ // Paper start - general item meta fixes - decoupled base colour and patterns
return meta;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java

Datei anzeigen

@ -13,35 +13,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
+ // Paper start - Improve java version check
+ boolean skip = Boolean.getBoolean("Paper.IgnoreJavaVersion");
float javaVersion = Float.parseFloat(System.getProperty("java.class.version"));
- if (javaVersion < 61.0) {
- System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 17. Check your Java version with the command 'java -version'.");
- return;
- }
- float javaVersion = Float.parseFloat(System.getProperty("java.class.version"));
- if (javaVersion > 66.0) {
- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 22 is supported.");
+ boolean isOldVersion = javaVersion < 61.0;
+ if (!skip && isOldVersion) {
+ System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 21. Check your Java version with the command 'java -version'. For more info see https://docs.papermc.io/misc/java-install");
return;
}
String javaVersionName = System.getProperty("java.version");
// J2SE SDK/JRE Version String Naming Convention
boolean isPreRelease = javaVersionName.contains("-");
- if (isPreRelease && javaVersion == 61.0) {
- System.err.println("Unsupported Java detected (" + javaVersionName + "). You are running an outdated, pre-release version. Only general availability versions of Java are supported. Please update your Java version.");
+ if (!skip && isPreRelease) {
+ System.err.println("Unsupported Java detected (" + javaVersionName + "). You are running an unsupported, non official, version. Only general availability versions of Java are supported. Please update your Java version. See https://docs.papermc.io/paper/faq#unsupported-java-detected-what-do-i-do for more information.");
return;
}
+ if (skip && (isOldVersion || isPreRelease)) {
+ System.err.println("Unsupported Java detected ("+ javaVersionName + "), but the check was skipped. Proceed with caution! ");
+ }
+ // Paper end - Improve java version check
- return;
+ // Paper start - Improve java version check
+ boolean skip = Boolean.getBoolean("Paper.IgnoreJavaVersion");
+ String javaVersionName = System.getProperty("java.version");
+ // J2SE SDK/JRE Version String Naming Convention
+ boolean isPreRelease = javaVersionName.contains("-");
+ if (isPreRelease) {
+ if (!skip) {
+ System.err.println("Unsupported Java detected (" + javaVersionName + "). You are running an unsupported, non official, version. Only general availability versions of Java are supported. Please update your Java version. See https://docs.papermc.io/paper/faq#unsupported-java-detected-what-do-i-do for more information.");
+ return;
+ }
+
+ System.err.println("Unsupported Java detected ("+ javaVersionName + "), but the check was skipped. Proceed with caution! ");
}
+ // Paper end - Improve java version check
try {
// Paper start - Handled by TerminalConsoleAppender
/*

Datei anzeigen

@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <git@lynxplay.dev>
Date: Fri, 19 Jul 2024 17:27:38 +0200
Subject: [PATCH] Move CraftComplexRecipe to extend CraftingRecipe
A craft complex recipe wraps a CustomRecipe, which itself is a
CraftingRecipe.
As such, this complex recipe should also be a crafting recipe.
diff --git a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
+++ b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
@@ -0,0 +0,0 @@ public abstract class CustomRecipe implements CraftingRecipe {
// CraftBukkit start
@Override
public Recipe toBukkitRecipe(NamespacedKey id) {
- return new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this);
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - start
+ final org.bukkit.craftbukkit.inventory.CraftComplexRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this);
+ recipe.setGroup(this.getGroup());
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
+ return recipe;
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - end
}
// CraftBukkit end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.ComplexRecipe;
import org.bukkit.inventory.ItemStack;
-public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe {
+public class CraftComplexRecipe extends org.bukkit.inventory.CraftingRecipe implements CraftRecipe, ComplexRecipe { // Paper - make CraftComplexRecipe extend CraftingRecipe
private final NamespacedKey key;
private final CustomRecipe recipe;
public CraftComplexRecipe(NamespacedKey key, CustomRecipe recipe) {
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - start
+ super();
+ super.key = key;
+ super.output = ItemStack.empty();
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - end
this.key = key;
this.recipe = recipe;
}

Datei anzeigen

@ -400,6 +400,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot
- return false;
- }
- int origCount = event.getItem().getAmount(); // Spigot
- ItemStack itemstack1 = HopperBlockEntity.addItem(blockEntity, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
- // CraftBukkit end
-
@ -409,7 +410,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }
-
- itemstack.setCount(j);
- if (j == 1) {
- // Spigot start
- itemstack.shrink(origCount - itemstack1.getCount());
- if (j <= world.spigotConfig.hopperAmount) {
- // Spigot end
- blockEntity.setItem(i, itemstack);
- }
- }
@ -444,6 +448,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot
+ // return false;
+ // }
+ // int origCount = event.getItem().getAmount(); // Spigot
+ // ItemStack itemstack1 = HopperBlockEntity.addItem(blockEntity, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ // // CraftBukkit end
+
@ -453,7 +458,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // }
+
+ // itemstack.setCount(j);
+ // if (j == 1) {
+ // // Spigot start
+ // itemstack.shrink(origCount - itemstack1.getCount());
+ // if (j <= world.spigotConfig.hopperAmount) {
+ // // Spigot end
+ // blockEntity.setItem(i, itemstack);
+ // }
+ // }
@ -511,6 +519,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
-
- return false;
- }
- int origCount = event.getItem().getAmount(); // Spigot
- ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
- // CraftBukkit end
-
@ -520,7 +529,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }
-
- itemstack.setCount(j);
- if (j == 1) {
- // Spigot start
- itemstack.shrink(origCount - itemstack1.getCount());
- if (j <= world.spigotConfig.hopperAmount) {
- // Spigot end
- iinventory.setItem(i, itemstack);
- }
+ // Paper start - Perf: Optimize Hoppers
@ -552,6 +564,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ // return false;
+ // }
+ // int origCount = event.getItem().getAmount(); // Spigot
+ // ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
+ // // CraftBukkit end
+
@ -561,7 +574,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // }
+
+ // itemstack.setCount(j);
+ // if (j == 1) {
+ // // Spigot start
+ // itemstack.shrink(origCount - itemstack1.getCount());
+ // if (j <= world.spigotConfig.hopperAmount) {
+ // // Spigot end
+ // iinventory.setItem(i, itemstack);
+ // }
+ // Paper end - Perf: Optimize Hoppers

Datei anzeigen

@ -1,119 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Fri, 21 Aug 2020 20:57:54 +0200
Subject: [PATCH] PortalCreateEvent needs to know its entity
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
net.minecraft.world.level.block.state.BlockState block = world.getBlockState(newblockposition);
if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically
- block.onPlace(world, newblockposition, oldBlock, true);
+ block.onPlace(world, newblockposition, oldBlock, true, context); // Paper - pass context
}
world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
diff --git a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
@@ -0,0 +0,0 @@ public abstract class BaseFireBlock extends Block {
@Override
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
+ // Paper start - UseOnContext param
+ this.onPlace(state, world, pos, oldState, notify, null);
+ }
+
+ @Override
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, @javax.annotation.Nullable net.minecraft.world.item.context.UseOnContext context) {
+ // Paper end - UseOnContext param
if (!oldState.is(state.getBlock())) {
if (BaseFireBlock.inPortalDimension(world)) {
Optional<PortalShape> optional = PortalShape.findEmptyPortalShape(world, pos, Direction.Axis.X);
if (optional.isPresent()) {
- ((PortalShape) optional.get()).createPortalBlocks();
+ ((PortalShape) optional.get()).createPortalBlocks(context); // Paper - pass context param
return;
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java
@@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock {
}
@Override
- protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
- super.onPlace(state, world, pos, oldState, notify);
+ // Paper start - UseOnContext param
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ super.onPlace(state, world, pos, oldState, notify, context);
+ // Paper end - UseOnContext param
world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
}
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement {
DebugPackets.sendNeighborsUpdatePacket(world, pos);
}
+ // Paper start - UseOnContext param
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ this.onPlace(state, world, pos, oldState, notify);
+ }
+ // Paper end - UseOnContext param
+
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot
}
@@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement {
this.getBlock().updateIndirectNeighbourShapes(this.asState(), world, pos, flags, maxUpdateDepth);
}
+ // Paper start
+ public void onPlace(Level world, BlockPos pos, BlockState state, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
+ this.getBlock().onPlace(this.asState(), world, pos, state, notify, context);
+ }
+ // Paper end
+
public void onPlace(Level world, BlockPos pos, BlockState state, boolean notify) {
this.getBlock().onPlace(this.asState(), world, pos, state, notify);
}
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
@@ -0,0 +0,0 @@ public class PortalShape {
}
// CraftBukkit start - return boolean
+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper
public boolean createPortalBlocks() {
+ // Paper start - UseOnContext param
+ return this.createPortalBlocks(null);
+ }
+
+ public boolean createPortalBlocks(@Nullable net.minecraft.world.item.context.UseOnContext useOnContext) {
+ // Paper end - UseOnContext param
org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld();
// Copy below for loop
@@ -0,0 +0,0 @@ public class PortalShape {
this.blocks.setBlock(blockposition, iblockdata, 18);
});
- PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) this.blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE);
+ PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blocks.getList(), bworld, useOnContext == null || useOnContext.getPlayer() == null ? null : useOnContext.getPlayer().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param
this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event);
if (event.isCancelled()) {

Datei anzeigen

@ -351,6 +351,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@Test
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList());
// add tags and loot tables for unit tests
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
+ // Paper start - load registry here to ensure bukkit object registry are correctly delayed if needed
+ try {
+ Class.forName("org.bukkit.Registry");
+ } catch (ClassNotFoundException ignored) {}
+ // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
REGISTRY_CUSTOM = layers.compositeAccess().freeze();
// Register vanilla pack
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/support/DummyServer.java

Datei anzeigen

@ -107,6 +107,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ (item, extras) -> new CraftMetaBlockState(item.getComponentsPatch(), CraftItemType.minecraftToBukkit(item.getItem()), extras),
(type, meta) -> new CraftMetaBlockState(meta, type.asMaterial()));
private static final ItemMetaData<ShieldMeta> SHIELD_META_DATA = new ItemMetaData<>(ShieldMeta.class,
- item -> new CraftMetaShield(item.getComponentsPatch()),
+ (item, extras) -> new CraftMetaShield(item.getComponentsPatch(), extras),
(type, meta) -> new CraftMetaShield(meta));
private static final ItemMetaData<TropicalFishBucketMeta> TROPICAL_FISH_BUCKET_META_DATA = new ItemMetaData<>(TropicalFishBucketMeta.class,
- item -> new CraftMetaTropicalFishBucket(item.getComponentsPatch()),
+ (item, extras) -> new CraftMetaTropicalFishBucket(item.getComponentsPatch(), extras),
@ -521,6 +526,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- CraftMetaMap.MAP_COLOR.TYPE,
- CraftMetaMap.MAP_ID.TYPE,
- CraftMetaPotion.POTION_CONTENTS.TYPE,
- CraftMetaShield.BASE_COLOR.TYPE,
- CraftMetaSkull.SKULL_PROFILE.TYPE,
- CraftMetaSkull.NOTE_BLOCK_SOUND.TYPE,
- CraftMetaSpawnEgg.ENTITY_TAG.TYPE,
@ -579,7 +585,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ map.put(CraftMetaArmor.class, Set.of(CraftMetaArmor.TRIM.TYPE));
+ map.put(CraftMetaArmorStand.class, Set.of(CraftMetaArmorStand.ENTITY_TAG.TYPE));
+ map.put(CraftMetaAxolotlBucket.class, Set.of(CraftMetaAxolotlBucket.ENTITY_TAG.TYPE, CraftMetaAxolotlBucket.BUCKET_ENTITY_TAG.TYPE));
+ map.put(CraftMetaBanner.class, Set.of(/*CraftMetaBlockState.BLOCK_ENTITY_TAG.NBT, */CraftMetaBanner.PATTERNS.TYPE)); // banner uses same tag as block state
+ map.put(CraftMetaBanner.class, Set.of(CraftMetaBanner.PATTERNS.TYPE)); // banner uses same tag as block state
+ map.put(CraftMetaShield.class, Set.of(CraftMetaShield.BASE_COLOR.TYPE, CraftMetaBanner.PATTERNS.TYPE));
+ map.put(CraftMetaBlockState.class, Set.of(CraftMetaBlockState.BLOCK_ENTITY_TAG.TYPE));
+ map.put(CraftMetaBook.class, Set.of(CraftMetaBook.BOOK_CONTENT.TYPE));
+ map.put(CraftMetaBookSigned.class, Set.of(CraftMetaBookSigned.BOOK_CONTENT.TYPE));
@ -706,6 +713,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
getOrEmpty(tag, CraftMetaPotion.POTION_CONTENTS).ifPresent((potionContents) -> {
potionContents.potion().ifPresent((potion) -> {
this.type = CraftPotionType.minecraftHolderToBukkit(potion);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaShield.java
@@ -0,0 +0,0 @@ public class CraftMetaShield extends CraftMetaItem implements ShieldMeta, BlockS
}
}
- CraftMetaShield(DataComponentPatch tag) {
- super(tag);
+ CraftMetaShield(DataComponentPatch tag, java.util.Set<net.minecraft.core.component.DataComponentType<?>> extraHandledDcts) { // Paper - improve checking handled tags in item meta
+ super(tag, extraHandledDcts); // Paper - improve checking handled tags in item meta
getOrEmpty(tag, CraftMetaShield.BASE_COLOR).ifPresent((color) -> {
this.banner = CraftMetaShield.getBlockState(DyeColor.getByWoolData((byte) color.getId()));
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java

@ -1 +1 @@
Subproject commit 3a3bea52057e094e4060239ad8a5ce16cf4c8dcb
Subproject commit 2ec53f498e32b3af989cb24672fc54dfab087154

@ -1 +1 @@
Subproject commit 403accd56333f091f4ef8b5f870591785e26cdfe
Subproject commit 8ee6fd1b8db9896590aa321d0199453de1fc35db

@ -1 +1 @@
Subproject commit 5bbef5ad33ea0f6a5f743ce123b385d3d22ff3f9
Subproject commit fb8fb722a327a2f9f097f2ded700ac5de8157408