mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Updated Upstream (Bukkit/CraftBukkit)
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: e2160a18 Make MapCursor#type not depends on deprecated values CraftBukkit Changes: 6ce172642 SPIGOT-7761: Ender pearl does not damage or spawn endermites f5a63f734 SPIGOT-7759: Chunk not there when requested in ChunkUnloadEvent 28287259c Remove unused import eb9a7dde0 SPIGOT-7757: Cannot set item in Stonecutter Inventory f8be9d752 Move deserialized removed unhandled tags to dedicated removedTags a7e576186 Fix potential mutability issue with CraftMetaItem copy constructor 995885452 SPIGOT-7741: Vanilla ItemComponent in commands can't remove components 9ef69aa0b PR-1284: Move ItemType <-> ItemMeta linking to a centralized place 3e82eafbe PR-1420: Fix DirectEntity and CausingEntity Damager for Creepers ignited by Player c23daa71f SPIGOT-7751: Fix crash caused by arrows from trial spawners Make MapCursor#type not depends on deprecated values SPIGOT-7761: Ender pearl does not damage or spawn endermites
This commit is contained in:
parent
9b3cf41d7a
commit
efb91589dc
20 changed files with 311 additions and 278 deletions
|
@ -4809,13 +4809,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+++ b/src/main/java/org/bukkit/map/MapCursor.java
|
+++ b/src/main/java/org/bukkit/map/MapCursor.java
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
@@ -0,0 +0,0 @@ public final class MapCursor {
|
||||||
private byte x, y;
|
private byte x, y;
|
||||||
private byte direction, type;
|
private byte direction;
|
||||||
private boolean visible;
|
private boolean visible;
|
||||||
- private String caption;
|
- private String caption;
|
||||||
+ private net.kyori.adventure.text.Component caption; // Paper
|
+ private net.kyori.adventure.text.Component caption; // Paper
|
||||||
|
private Type type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the map cursor.
|
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
@@ -0,0 +0,0 @@ public final class MapCursor {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -4838,8 +4838,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
* @param type The type (color/style) of the map cursor.
|
* @param type The type (color/style) of the map cursor.
|
||||||
* @param visible Whether the cursor is visible by default.
|
* @param visible Whether the cursor is visible by default.
|
||||||
* @param caption cursor caption
|
* @param caption cursor caption
|
||||||
- * @deprecated Magic value
|
- * @deprecated Magic value, use {@link #MapCursor(byte, byte, byte, Type, boolean, String)}
|
||||||
+ * @deprecated Magic value. Use {@link #MapCursor(byte, byte, byte, byte, boolean, net.kyori.adventure.text.Component)}
|
+ * @deprecated Magic value. Use {@link #MapCursor(byte, byte, byte, Type, boolean, net.kyori.adventure.text.Component)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable String caption) {
|
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable String caption) {
|
||||||
|
@ -4849,7 +4849,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
- this.caption = caption;
|
- this.caption = caption;
|
||||||
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
|
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
|
||||||
}
|
+ }
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ /**
|
+ /**
|
||||||
+ * Initialize the map cursor.
|
+ * Initialize the map cursor.
|
||||||
|
@ -4867,7 +4867,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ this.x = x; this.y = y; this.visible = visible; this.caption = caption;
|
+ this.x = x; this.y = y; this.visible = visible; this.caption = caption;
|
||||||
+ setDirection(direction);
|
+ setDirection(direction);
|
||||||
+ setRawType(type);
|
+ setRawType(type);
|
||||||
+ }
|
}
|
||||||
+ /**
|
+ /**
|
||||||
+ * Initialize the map cursor.
|
+ * Initialize the map cursor.
|
||||||
+ *
|
+ *
|
||||||
|
@ -4889,7 +4889,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
* Initialize the map cursor.
|
* Initialize the map cursor.
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
@@ -0,0 +0,0 @@ public final class MapCursor {
|
||||||
setDirection(direction);
|
setDirection(direction);
|
||||||
setType(type);
|
this.type = type;
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
- this.caption = caption;
|
- this.caption = caption;
|
||||||
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
|
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
|
||||||
|
@ -4901,11 +4901,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ /**
|
/**
|
||||||
+ * Gets the caption on this cursor.
|
* Gets the caption on this cursor.
|
||||||
+ *
|
*
|
||||||
+ * @return caption
|
* @return caption
|
||||||
+ */
|
*/
|
||||||
+ public net.kyori.adventure.text.@Nullable Component caption() {
|
+ public net.kyori.adventure.text.@Nullable Component caption() {
|
||||||
+ return this.caption;
|
+ return this.caption;
|
||||||
+ }
|
+ }
|
||||||
|
@ -4918,12 +4918,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ this.caption = caption;
|
+ this.caption = caption;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
/**
|
+ /**
|
||||||
* Gets the caption on this cursor.
|
+ * Gets the caption on this cursor.
|
||||||
*
|
+ *
|
||||||
* @return caption
|
+ * @return caption
|
||||||
+ * @deprecated in favour of {@link #caption()}
|
+ * @deprecated in favour of {@link #caption()}
|
||||||
*/
|
+ */
|
||||||
@Nullable
|
@Nullable
|
||||||
+ @Deprecated // Paper
|
+ @Deprecated // Paper
|
||||||
public String getCaption() {
|
public String getCaption() {
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
|
||||||
Date: Fri, 24 May 2024 20:19:07 +0200
|
|
||||||
Subject: [PATCH] Allow to define new map cursor types
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/map/MapCursor.java b/src/main/java/org/bukkit/map/MapCursor.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/org/bukkit/map/MapCursor.java
|
|
||||||
+++ b/src/main/java/org/bukkit/map/MapCursor.java
|
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "1.20.2") // Paper
|
|
||||||
public void setRawType(byte type) {
|
|
||||||
- if (type < 0 || type > 34) {
|
|
||||||
- throw new IllegalArgumentException("Type must be in the range 0-34");
|
|
||||||
+ if (type < 0 || type > Type.UPPER_MAP_CURSOR_TYPE_BOUND) { // Paper
|
|
||||||
+ throw new IllegalArgumentException("Type must be in the range 0-" + Type.UPPER_MAP_CURSOR_TYPE_BOUND); // Paper
|
|
||||||
}
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
|
||||||
TRIAL_CHAMBERS(34, "trial_chambers")
|
|
||||||
;
|
|
||||||
|
|
||||||
+ static final int UPPER_MAP_CURSOR_TYPE_BOUND = Type.values().length - 1; // Paper - cached max value of Type
|
|
||||||
+
|
|
||||||
private byte value;
|
|
||||||
private final NamespacedKey key;
|
|
||||||
|
|
|
@ -1690,7 +1690,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- @Deprecated
|
- @Deprecated
|
||||||
+ @org.jetbrains.annotations.ApiStatus.Internal // Paper
|
+ @org.jetbrains.annotations.ApiStatus.Internal // Paper
|
||||||
public byte getRawType() {
|
public byte getRawType() {
|
||||||
return type;
|
return type.value;
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
@@ -0,0 +0,0 @@ public final class MapCursor {
|
||||||
* Set the type of this cursor.
|
* Set the type of this cursor.
|
||||||
|
@ -1702,8 +1702,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- @Deprecated
|
- @Deprecated
|
||||||
+ @Deprecated(forRemoval = true, since = "1.20.2") // Paper
|
+ @Deprecated(forRemoval = true, since = "1.20.2") // Paper
|
||||||
public void setRawType(byte type) {
|
public void setRawType(byte type) {
|
||||||
if (type < 0 || type > 34) {
|
Type enumType = Type.byValue(type);
|
||||||
throw new IllegalArgumentException("Type must be in the range 0-34");
|
Preconditions.checkArgument(enumType != null, "Unknown type by id %s", type);
|
||||||
@@ -0,0 +0,0 @@ public final class MapCursor {
|
@@ -0,0 +0,0 @@ public final class MapCursor {
|
||||||
* Gets the internal value of the cursor.
|
* Gets the internal value of the cursor.
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,19 +12,26 @@ starting point for future additions in this area.
|
||||||
|
|
||||||
Fixes GH-559
|
Fixes GH-559
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han
|
@@ -0,0 +0,0 @@
|
||||||
private Class<M> getItemMetaClass(Item item) {
|
package org.bukkit.craftbukkit.inventory;
|
||||||
ItemMeta meta = new ItemStack(this.asMaterial()).getItemMeta();
|
|
||||||
if (meta != null) {
|
+import com.destroystokyo.paper.inventory.meta.ArmorStandMeta;
|
||||||
- if (CraftMetaEntityTag.class != meta.getClass() && CraftMetaArmorStand.class != meta.getClass()) {
|
import java.util.function.BiFunction;
|
||||||
+ if (CraftMetaEntityTag.class != meta.getClass()/* && CraftMetaArmorStand.class != meta.getClass()*/) { // Paper - CraftMetaArmorStand is implemented in the API via ArmorStandMeta.
|
import java.util.function.Function;
|
||||||
return (Class<M>) meta.getClass().getInterfaces()[0];
|
import net.minecraft.world.item.ItemStack;
|
||||||
}
|
@@ -0,0 +0,0 @@ public final class CraftItemMetas {
|
||||||
}
|
item -> new CraftMetaSpawnEgg(item.getComponentsPatch()),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaSpawnEgg spawnEgg ? spawnEgg : new CraftMetaSpawnEgg(meta));
|
||||||
|
|
||||||
|
- private static final ItemMetaData<ItemMeta> ARMOR_STAND_META_DATA = new ItemMetaData<>(ItemMeta.class,
|
||||||
|
+ private static final ItemMetaData<ArmorStandMeta> ARMOR_STAND_META_DATA = new ItemMetaData<>(ArmorStandMeta.class, // paper
|
||||||
|
item -> new CraftMetaArmorStand(item.getComponentsPatch()),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaArmorStand armorStand ? armorStand : new CraftMetaArmorStand(meta));
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||||
|
|
|
@ -1070,8 +1070,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- });
|
- });
|
||||||
+ // Paper - RegistryAccess
|
+ // Paper - RegistryAccess
|
||||||
|
|
||||||
// Paper start - testing additions
|
when(instance.getTag(any(), any(), any())).then(mock -> {
|
||||||
final Thread currentThread = Thread.currentThread();
|
String registry = mock.getArgument(0);
|
||||||
diff --git a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java
|
diff --git a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java
|
--- a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java
|
||||||
|
|
|
@ -5121,7 +5121,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null);
|
return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
|
|
|
@ -11605,7 +11605,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ // ticket level state
|
+ // ticket level state
|
||||||
+ private int oldTicketLevel = ChunkHolderManager.MAX_TICKET_LEVEL + 1;
|
+ public int oldTicketLevel = ChunkHolderManager.MAX_TICKET_LEVEL + 1;
|
||||||
+ private int currentTicketLevel = ChunkHolderManager.MAX_TICKET_LEVEL + 1;
|
+ private int currentTicketLevel = ChunkHolderManager.MAX_TICKET_LEVEL + 1;
|
||||||
+
|
+
|
||||||
+ public int getTicketLevel() {
|
+ public int getTicketLevel() {
|
||||||
|
@ -22635,6 +22635,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
public LevelChunk getFullChunkNow() {
|
||||||
|
// Note: We use the oldTicketLevel for isLoaded checks.
|
||||||
|
- if (!ChunkLevel.fullStatus(this.oldTicketLevel).isOrAfter(FullChunkStatus.FULL)) return null;
|
||||||
|
+ if (!ChunkLevel.fullStatus(this.newChunkHolder.oldTicketLevel).isOrAfter(FullChunkStatus.FULL)) return null; // Paper - rewrite chunk system
|
||||||
|
return this.getFullChunkNowUnchecked();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class ChunkHolder extends GenerationChunkHolder {
|
@@ -0,0 +0,0 @@ public class ChunkHolder extends GenerationChunkHolder {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
|
@ -24862,12 +24869,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ };
|
+ };
|
||||||
|
|
||||||
- return this.chunkAbsent(playerchunk, l) ? GenerationChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.scheduleChunkGenerationTask(leastStatus, this.chunkMap);
|
- return this.chunkAbsent(playerchunk, l) ? GenerationChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.scheduleChunkGenerationTask(leastStatus, this.chunkMap);
|
||||||
|
- }
|
||||||
+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(
|
+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(
|
||||||
+ chunkX, chunkZ, leastStatus, true,
|
+ chunkX, chunkZ, leastStatus, true,
|
||||||
+ ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER,
|
+ ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER,
|
||||||
+ complete
|
+ complete
|
||||||
+ );
|
+ );
|
||||||
+
|
|
||||||
|
- private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) {
|
||||||
|
- return holder == null || holder.oldTicketLevel > maxLevel; // CraftBukkit using oldTicketLevel for isLoaded checks
|
||||||
+ return ret;
|
+ return ret;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ // can return now
|
+ // can return now
|
||||||
|
@ -24876,9 +24886,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper end - rewrite chunk system
|
+ // Paper end - rewrite chunk system
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) {
|
|
||||||
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasChunk(int x, int z) {
|
public boolean hasChunk(int x, int z) {
|
||||||
- ChunkHolder playerchunk = this.getVisibleChunkIfPresent((new ChunkPos(x, z)).toLong());
|
- ChunkHolder playerchunk = this.getVisibleChunkIfPresent((new ChunkPos(x, z)).toLong());
|
||||||
|
|
|
@ -9,18 +9,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
this.damage = meta.damage;
|
|
||||||
this.maxDamage = meta.maxDamage;
|
this.maxDamage = meta.maxDamage;
|
||||||
this.unhandledTags = meta.unhandledTags;
|
this.unhandledTags.copy(meta.unhandledTags.build());
|
||||||
|
this.removedTags.addAll(meta.removedTags);
|
||||||
- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
|
- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
|
||||||
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned()); // Paper - deep clone NBT tags
|
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned()); // Paper - deep clone NBT tags
|
||||||
|
|
||||||
this.customTag = meta.customTag;
|
this.customTag = meta.customTag;
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
if (this.customTag != null) {
|
|
||||||
clone.customTag = this.customTag.copy();
|
clone.customTag = this.customTag.copy();
|
||||||
}
|
}
|
||||||
|
clone.removedTags = Sets.newHashSet(this.removedTags);
|
||||||
- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
||||||
+ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY); // Paper - deep clone NBT tags
|
+ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY); // Paper - deep clone NBT tags
|
||||||
clone.hideFlag = this.hideFlag;
|
clone.hideFlag = this.hideFlag;
|
||||||
|
|
|
@ -27,12 +27,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
||||||
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
||||||
- if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
- if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
||||||
|
+ // Paper start - don't lose unhandled tags
|
||||||
+ if (key.getValue().isEmpty()) {
|
+ if (key.getValue().isEmpty()) {
|
||||||
+ this.unhandledTags.remove(key.getKey());
|
+ this.unhandledTags.remove(key.getKey());
|
||||||
+ } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
+ } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
||||||
key.getValue().ifPresentOrElse((value) -> {
|
+ // Paper end - don't lose unhandled tags
|
||||||
|
key.getValue().ifPresent((value) -> {
|
||||||
this.unhandledTags.set((DataComponentType) key.getKey(), value);
|
this.unhandledTags.set((DataComponentType) key.getKey(), value);
|
||||||
}, () -> {
|
});
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,4 +46,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }, () -> itemTag.remove(e.getKey()));
|
+ }, () -> itemTag.remove(e.getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag customTag = (this.customTag != null) ? this.customTag.copy() : null;
|
for (DataComponentType<?> removed : this.removedTags) {
|
||||||
|
|
|
@ -14,7 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
private boolean sweep = false;
|
private boolean sweep = false;
|
||||||
private boolean melting = false;
|
private boolean melting = false;
|
||||||
private boolean poison = false;
|
private boolean poison = false;
|
||||||
- private Entity customEntityDamager = null; // This field is a helper for when causing entity damage is not set by vanilla
|
- private Entity customEntityDamager = null; // This field is a helper for when direct entity damage is not set by vanilla
|
||||||
|
- private Entity customCausingEntityDamager = null; // This field is a helper for when causing entity damage is not set by vanilla
|
||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ private Entity customEventDamager = null; // This field is a helper for when causing entity damage is not set by vanilla // Paper - fix DamageSource API
|
+ private Entity customEventDamager = null; // This field is a helper for when causing entity damage is not set by vanilla // Paper - fix DamageSource API
|
||||||
|
|
||||||
|
@ -26,23 +27,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
- public Entity getDamager() {
|
- public Entity getDamager() {
|
||||||
- return (this.customEntityDamager != null) ? this.customEntityDamager : this.directEntity;
|
- return (this.customEntityDamager != null) ? this.customEntityDamager : this.directEntity;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public Entity getCausingDamager() {
|
||||||
|
- return (this.customCausingEntityDamager != null) ? this.customCausingEntityDamager : this.causingEntity;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public DamageSource customEntityDamager(Entity entity) {
|
||||||
|
- // This method is not intended for change the causing entity if is already set
|
||||||
|
- // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity
|
||||||
|
- if (this.customEntityDamager != null || this.directEntity == entity || this.causingEntity == entity) {
|
||||||
|
- return this;
|
||||||
|
- }
|
||||||
|
- DamageSource damageSource = this.cloneInstance();
|
||||||
|
- damageSource.customEntityDamager = entity;
|
||||||
|
- return damageSource;
|
||||||
+ // Paper start - fix DamageSource API
|
+ // Paper start - fix DamageSource API
|
||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ public Entity getCustomEventDamager() {
|
+ public Entity getCustomEventDamager() {
|
||||||
+ return (this.customEventDamager != null) ? this.customEventDamager : this.directEntity;
|
+ return (this.customEventDamager != null) ? this.customEventDamager : this.directEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
- public DamageSource customEntityDamager(Entity entity) {
|
- public DamageSource customCausingEntityDamager(Entity entity) {
|
||||||
- // This method is not intended for change the causing entity if is already set
|
- // This method is not intended for change the causing entity if is already set
|
||||||
- // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity
|
- // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity
|
||||||
- if (this.customEntityDamager != null || this.directEntity == entity || this.causingEntity == entity) {
|
- if (this.customCausingEntityDamager != null || this.directEntity == entity || this.causingEntity == entity) {
|
||||||
- return this;
|
- return this;
|
||||||
+ public DamageSource customEventDamager(Entity entity) {
|
+ public DamageSource customEventDamager(Entity entity) {
|
||||||
+ if (this.directEntity != null) {
|
+ if (this.directEntity != null) {
|
||||||
+ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper)");
|
+ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper)");
|
||||||
}
|
}
|
||||||
DamageSource damageSource = this.cloneInstance();
|
DamageSource damageSource = this.cloneInstance();
|
||||||
- damageSource.customEntityDamager = entity;
|
- damageSource.customCausingEntityDamager = entity;
|
||||||
+ damageSource.customEventDamager = entity;
|
+ damageSource.customEventDamager = entity;
|
||||||
+ // Paper end - fix DamageSource API
|
+ // Paper end - fix DamageSource API
|
||||||
return damageSource;
|
return damageSource;
|
||||||
|
@ -114,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
this.dead = true;
|
this.dead = true;
|
||||||
- this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit
|
- this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit
|
||||||
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this)
|
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this)
|
||||||
this.spawnLingeringCloud();
|
this.spawnLingeringCloud();
|
||||||
this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED);
|
this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED);
|
||||||
|
@ -164,6 +180,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageSource.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageSource.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftDamageSource implements DamageSource {
|
@@ -0,0 +0,0 @@ public class CraftDamageSource implements DamageSource {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity getCausingEntity() {
|
||||||
|
- net.minecraft.world.entity.Entity entity = this.getHandle().getCausingDamager();
|
||||||
|
+ net.minecraft.world.entity.Entity entity = this.getHandle().getCustomEventDamager(); // Paper
|
||||||
|
return (entity != null) ? entity.getBukkitEntity() : null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getDirectEntity() {
|
public org.bukkit.entity.Entity getDirectEntity() {
|
||||||
- net.minecraft.world.entity.Entity entity = this.getHandle().getDamager();
|
- net.minecraft.world.entity.Entity entity = this.getHandle().getDamager();
|
||||||
|
|
|
@ -82,23 +82,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
||||||
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(unhandled));
|
|
||||||
try {
|
try {
|
||||||
CompoundTag unhandledTag = NbtIo.readCompressed(buf, NbtAccounter.unlimitedHeap());
|
CompoundTag unhandledTag = NbtIo.readCompressed(buf, NbtAccounter.unlimitedHeap());
|
||||||
- this.unhandledTags.copy(DataComponentPatch.CODEC.parse(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), unhandledTag).result().get());
|
DataComponentPatch unhandledPatch = DataComponentPatch.CODEC.parse(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), unhandledTag).result().get();
|
||||||
|
- this.unhandledTags.copy(unhandledPatch);
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ final net.minecraft.core.component.DataComponentPatch patch = net.minecraft.core.component.DataComponentPatch.CODEC.parse(net.minecraft.server.MinecraftServer.getDefaultRegistryAccess().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE), unhandledTag).result().get();
|
+ CraftMetaItem.getOrEmpty(unhandledPatch, CraftMetaItem.CAN_PLACE_ON).ifPresent(data -> {
|
||||||
+ CraftMetaItem.getOrEmpty(patch, CraftMetaItem.CAN_PLACE_ON).ifPresent(data -> {
|
|
||||||
+ this.canPlaceOnPredicates = List.copyOf(data.predicates);
|
+ this.canPlaceOnPredicates = List.copyOf(data.predicates);
|
||||||
+ });
|
+ });
|
||||||
+ CraftMetaItem.getOrEmpty(patch, CraftMetaItem.CAN_BREAK).ifPresent(data -> {
|
+ CraftMetaItem.getOrEmpty(unhandledPatch, CraftMetaItem.CAN_BREAK).ifPresent(data -> {
|
||||||
+ this.canBreakPredicates = List.copyOf(data.predicates);
|
+ this.canBreakPredicates = List.copyOf(data.predicates);
|
||||||
+ });
|
+ });
|
||||||
+ this.unhandledTags.copy(patch.forget(type -> type == CraftMetaItem.CAN_PLACE_ON.TYPE || type == CraftMetaItem.CAN_BREAK.TYPE));
|
+ this.unhandledTags.copy(unhandledPatch.forget(type -> type == CraftMetaItem.CAN_PLACE_ON.TYPE || type == CraftMetaItem.CAN_BREAK.TYPE));
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
|
for (Entry<DataComponentType<?>, Optional<?>> entry : unhandledPatch.entrySet()) {
|
||||||
}
|
// Move removed unhandled tags to dedicated removedTags
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
itemTag.put(CraftMetaItem.MAX_DAMAGE, this.maxDamage);
|
itemTag.put(CraftMetaItem.MAX_DAMAGE, this.maxDamage);
|
||||||
}
|
}
|
||||||
|
@ -119,8 +118,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
@Overridden
|
@Overridden
|
||||||
boolean isEmpty() {
|
boolean isEmpty() {
|
||||||
- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null);
|
- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null);
|
||||||
+ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper
|
+ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paper start
|
// Paper start
|
||||||
|
@ -187,8 +186,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
if (!this.persistentDataContainer.isEmpty()) { // Store custom tags, wrapped in their compound
|
if (!this.removedTags.isEmpty()) {
|
||||||
builder.put(CraftMetaItem.BUKKIT_CUSTOM_TAG.BUKKIT, this.persistentDataContainer.serialize());
|
RegistryAccess registryAccess = CraftRegistry.getMinecraftRegistry();
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
CraftMetaItem.MAX_DAMAGE.TYPE,
|
CraftMetaItem.MAX_DAMAGE.TYPE,
|
||||||
CraftMetaItem.CUSTOM_DATA.TYPE,
|
CraftMetaItem.CUSTOM_DATA.TYPE,
|
||||||
|
|
|
@ -358,8 +358,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|
||||||
@Override
|
|
||||||
public CraftMetaBlockState clone() {
|
public CraftMetaBlockState clone() {
|
||||||
CraftMetaBlockState meta = (CraftMetaBlockState) super.clone();
|
CraftMetaBlockState meta = (CraftMetaBlockState) super.clone();
|
||||||
- if (this.blockEntityTag != null) {
|
- if (this.blockEntityTag != null) {
|
||||||
|
@ -531,9 +529,9 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableAr
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftMetaColorableArmor extends CraftMetaArmor implements Colorable
|
@@ -0,0 +0,0 @@ import org.bukkit.inventory.meta.ColorableArmorMeta;
|
||||||
Material.WOLF_ARMOR
|
@DelegateDeserialization(SerializableMeta.class)
|
||||||
);
|
public class CraftMetaColorableArmor extends CraftMetaArmor implements ColorableArmorMeta {
|
||||||
|
|
||||||
- private Color color = DEFAULT_LEATHER_COLOR;
|
- private Color color = DEFAULT_LEATHER_COLOR;
|
||||||
+ private Integer color; // Paper - keep color component consistent with vanilla (top byte is ignored)
|
+ private Integer color; // Paper - keep color component consistent with vanilla (top byte is ignored)
|
||||||
|
@ -889,15 +887,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
||||||
|
|
||||||
@Overridden
|
|
||||||
boolean isEmpty() {
|
|
||||||
- return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper
|
|
||||||
+ return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.attributeModifiers != null || this.customTag != null || this.canPlaceOnPredicates != null || this.canBreakPredicates != null); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paper start
|
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1059,8 +1048,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- && (this.hasAttributeModifiers() ? that.hasAttributeModifiers() && CraftMetaItem.compareModifiers(this.attributeModifiers, that.attributeModifiers) : !that.hasAttributeModifiers())
|
- && (this.hasAttributeModifiers() ? that.hasAttributeModifiers() && CraftMetaItem.compareModifiers(this.attributeModifiers, that.attributeModifiers) : !that.hasAttributeModifiers())
|
||||||
+ && (this.attributeModifiers != null ? that.attributeModifiers != null && CraftMetaItem.compareModifiers(this.attributeModifiers, that.attributeModifiers) : that.attributeModifiers == null) // Paper - track only null modifiers
|
+ && (this.attributeModifiers != null ? that.attributeModifiers != null && CraftMetaItem.compareModifiers(this.attributeModifiers, that.attributeModifiers) : that.attributeModifiers == null) // Paper - track only null modifiers
|
||||||
&& (this.unhandledTags.equals(that.unhandledTags))
|
&& (this.unhandledTags.equals(that.unhandledTags))
|
||||||
|
&& (this.removedTags.equals(that.removedTags))
|
||||||
&& (Objects.equals(this.customTag, that.customTag))
|
&& (Objects.equals(this.customTag, that.customTag))
|
||||||
&& (this.persistentDataContainer.equals(that.persistentDataContainer))
|
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
hash = 61 * hash + (this.hasTool() ? this.tool.hashCode() : 0);
|
hash = 61 * hash + (this.hasTool() ? this.tool.hashCode() : 0);
|
||||||
hash = 61 * hash + (this.hasJukeboxPlayable() ? this.jukebox.hashCode() : 0);
|
hash = 61 * hash + (this.hasJukeboxPlayable() ? this.jukebox.hashCode() : 0);
|
||||||
|
|
|
@ -6189,7 +6189,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
public LevelChunk getFullChunkNow() {
|
public LevelChunk getFullChunkNow() {
|
||||||
return (LevelChunk) this.getChunkIfPresent(ChunkStatus.FULL);
|
// Note: We use the oldTicketLevel for isLoaded checks.
|
||||||
@@ -0,0 +0,0 @@ public class ChunkHolder extends GenerationChunkHolder {
|
@@ -0,0 +0,0 @@ public class ChunkHolder extends GenerationChunkHolder {
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
|
@ -395,7 +395,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
@Override
|
@Override
|
||||||
public FireworkMeta getFireworkMeta() {
|
public FireworkMeta getFireworkMeta() {
|
||||||
- return (FireworkMeta) this.item.getItemMeta();
|
- return (FireworkMeta) this.item.getItemMeta();
|
||||||
+ return (FireworkMeta) CraftItemStack.getItemMeta(this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM), Material.FIREWORK_ROCKET); // Paper - Expose firework item directly
|
+ return (FireworkMeta) CraftItemStack.getItemMeta(this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM), org.bukkit.inventory.ItemType.FIREWORK_ROCKET); // Paper - Expose firework item directly
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -643,7 +643,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start - Projectile API
|
+ // Paper start - Projectile API
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public org.bukkit.inventory.meta.PotionMeta getPotionMeta() {
|
+ public org.bukkit.inventory.meta.PotionMeta getPotionMeta() {
|
||||||
+ return (org.bukkit.inventory.meta.PotionMeta) CraftItemStack.getItemMeta(this.getHandle().getItem(), Material.SPLASH_POTION);
|
+ return (org.bukkit.inventory.meta.PotionMeta) CraftItemStack.getItemMeta(this.getHandle().getItem(), org.bukkit.inventory.ItemType.SPLASH_POTION);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
@ -748,16 +748,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item) {
|
public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item) {
|
||||||
+ return getItemMeta(item, CraftItemStack.getType(item));
|
+ return getItemMeta(item, null);
|
||||||
+ }
|
+ }
|
||||||
+ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, Material material) {
|
+ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, org.bukkit.inventory.ItemType metaForType) {
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
if (!CraftItemStack.hasItemMeta(item)) {
|
if (!CraftItemStack.hasItemMeta(item)) {
|
||||||
- return CraftItemFactory.instance().getItemMeta(CraftItemStack.getType(item));
|
return CraftItemFactory.instance().getItemMeta(CraftItemStack.getType(item));
|
||||||
+ return CraftItemFactory.instance().getItemMeta(material); // Paper
|
|
||||||
}
|
}
|
||||||
- switch (CraftItemStack.getType(item)) {
|
|
||||||
+ switch (material) { // Paper
|
+ if (metaForType != null) { return ((CraftItemType<?>) metaForType).getItemMeta(item); } // Paper
|
||||||
case WRITTEN_BOOK:
|
return ((CraftItemType<?>) CraftItemType.minecraftToBukkitNew(item.getItem())).getItemMeta(item);
|
||||||
return new CraftMetaBookSigned(item.getComponentsPatch());
|
}
|
||||||
case WRITABLE_BOOK:
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
return false; // CraftBukkit - Return event status
|
return true; // CraftBukkit - Return event status
|
||||||
}
|
}
|
||||||
|
|
||||||
- PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause);
|
- PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause);
|
||||||
|
|
|
@ -355,7 +355,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||||
@@ -0,0 +0,0 @@ public final class DummyServer {
|
@@ -0,0 +0,0 @@ public final class DummyServer {
|
||||||
return registers.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, AbstractTestingBase.REGISTRY_CUSTOM));
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
+ // Paper start - testing additions
|
+ // Paper start - testing additions
|
||||||
|
|
|
@ -4,30 +4,19 @@ Date: Tue, 11 Jul 2023 11:22:30 -0700
|
||||||
Subject: [PATCH] fix item meta for tadpole buckets
|
Subject: [PATCH] fix item meta for tadpole buckets
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory {
|
@@ -0,0 +0,0 @@ public final class CraftItemMetas {
|
||||||
case COD_BUCKET:
|
if (itemType == ItemType.SUSPICIOUS_STEW) {
|
||||||
case PUFFERFISH_BUCKET:
|
return CraftItemMetas.asType(CraftItemMetas.SUSPICIOUS_STEW_META_DATA);
|
||||||
case SALMON_BUCKET:
|
}
|
||||||
+ case TADPOLE_BUCKET: // Paper
|
- if (itemType == ItemType.COD_BUCKET || itemType == ItemType.PUFFERFISH_BUCKET
|
||||||
case ITEM_FRAME:
|
+ if (itemType == ItemType.COD_BUCKET || itemType == ItemType.PUFFERFISH_BUCKET || itemType == ItemType.TADPOLE_BUCKET // Paper
|
||||||
case GLOW_ITEM_FRAME:
|
|| itemType == ItemType.SALMON_BUCKET || itemType == ItemType.ITEM_FRAME
|
||||||
case PAINTING:
|
|| itemType == ItemType.GLOW_ITEM_FRAME || itemType == ItemType.PAINTING) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
return CraftItemMetas.asType(CraftItemMetas.ENTITY_TAG_META_DATA);
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case COD_BUCKET:
|
|
||||||
case PUFFERFISH_BUCKET:
|
|
||||||
case SALMON_BUCKET:
|
|
||||||
+ case TADPOLE_BUCKET: // Paper
|
|
||||||
case ITEM_FRAME:
|
|
||||||
case GLOW_ITEM_FRAME:
|
|
||||||
case PAINTING:
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java
|
||||||
|
|
|
@ -4,6 +4,155 @@ Date: Mon, 10 Jul 2023 16:10:15 -0700
|
||||||
Subject: [PATCH] improve checking handled tags in itemmeta
|
Subject: [PATCH] improve checking handled tags in itemmeta
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java
|
||||||
|
@@ -0,0 +0,0 @@ import org.bukkit.inventory.meta.TropicalFishBucketMeta;
|
||||||
|
|
||||||
|
public final class CraftItemMetas {
|
||||||
|
|
||||||
|
- public record ItemMetaData<I extends ItemMeta>(Class<I> metaClass, Function<ItemStack, I> fromItemStack,
|
||||||
|
+ public record ItemMetaData<I extends ItemMeta>(Class<I> metaClass, BiFunction<ItemStack, java.util.Set<net.minecraft.core.component.DataComponentType<?>>, I> fromItemStack,
|
||||||
|
BiFunction<ItemType.Typed<I>, CraftMetaItem, I> fromItemMeta) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ItemMetaData<ItemMeta> EMPTY_META_DATA = new ItemMetaData<>(ItemMeta.class,
|
||||||
|
- item -> null,
|
||||||
|
+ (item, extras) -> null,
|
||||||
|
(type, meta) -> null);
|
||||||
|
|
||||||
|
private static final ItemMetaData<ItemMeta> ITEM_META_DATA = new ItemMetaData<>(ItemMeta.class,
|
||||||
|
- item -> new CraftMetaItem(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaItem(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> new CraftMetaItem(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<BookMeta> SIGNED_BOOK_META_DATA = new ItemMetaData<>(BookMeta.class,
|
||||||
|
- item -> new CraftMetaBookSigned(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaBookSigned(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaBookSigned signed ? signed : new CraftMetaBookSigned(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<BookMeta> WRITABLE_BOOK_META_DATA = new ItemMetaData<>(BookMeta.class,
|
||||||
|
- item -> new CraftMetaBook(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaBook(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta != null && meta.getClass().equals(CraftMetaBook.class) ? (BookMeta) meta : new CraftMetaBook(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<SkullMeta> SKULL_META_DATA = new ItemMetaData<>(SkullMeta.class,
|
||||||
|
- item -> new CraftMetaSkull(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaSkull(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaSkull skull ? skull : new CraftMetaSkull(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<ArmorMeta> ARMOR_META_DATA = new ItemMetaData<>(ArmorMeta.class,
|
||||||
|
- item -> new CraftMetaArmor(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaArmor(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta != null && meta.getClass().equals(CraftMetaArmor.class) ? (ArmorMeta) meta : new CraftMetaArmor(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<ColorableArmorMeta> COLORABLE_ARMOR_META_DATA = new ItemMetaData<>(ColorableArmorMeta.class,
|
||||||
|
- item -> new CraftMetaColorableArmor(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaColorableArmor(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof ColorableArmorMeta colorable ? colorable : new CraftMetaColorableArmor(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<LeatherArmorMeta> LEATHER_ARMOR_META_DATA = new ItemMetaData<>(LeatherArmorMeta.class,
|
||||||
|
- item -> new CraftMetaLeatherArmor(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaLeatherArmor(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaLeatherArmor leather ? leather : new CraftMetaLeatherArmor(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<PotionMeta> POTION_META_DATA = new ItemMetaData<>(PotionMeta.class,
|
||||||
|
- item -> new CraftMetaPotion(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaPotion(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaPotion potion ? potion : new CraftMetaPotion(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<MapMeta> MAP_META_DATA = new ItemMetaData<>(MapMeta.class,
|
||||||
|
- item -> new CraftMetaMap(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaMap(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaMap map ? map : new CraftMetaMap(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<FireworkMeta> FIREWORK_META_DATA = new ItemMetaData<>(FireworkMeta.class,
|
||||||
|
- item -> new CraftMetaFirework(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaFirework(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaFirework firework ? firework : new CraftMetaFirework(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<FireworkEffectMeta> CHARGE_META_DATA = new ItemMetaData<>(FireworkEffectMeta.class,
|
||||||
|
- item -> new CraftMetaCharge(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaCharge(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaCharge charge ? charge : new CraftMetaCharge(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<EnchantmentStorageMeta> ENCHANTED_BOOK_META_DATA = new ItemMetaData<>(EnchantmentStorageMeta.class,
|
||||||
|
- item -> new CraftMetaEnchantedBook(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaEnchantedBook(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaEnchantedBook enchantedBook ? enchantedBook : new CraftMetaEnchantedBook(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<BannerMeta> BANNER_META_DATA = new ItemMetaData<>(BannerMeta.class,
|
||||||
|
- item -> new CraftMetaBanner(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaBanner(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaBanner banner ? banner : new CraftMetaBanner(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<SpawnEggMeta> SPAWN_EGG_META_DATA = new ItemMetaData<>(SpawnEggMeta.class,
|
||||||
|
- item -> new CraftMetaSpawnEgg(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaSpawnEgg(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaSpawnEgg spawnEgg ? spawnEgg : new CraftMetaSpawnEgg(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<ArmorStandMeta> ARMOR_STAND_META_DATA = new ItemMetaData<>(ArmorStandMeta.class, // paper
|
||||||
|
- item -> new CraftMetaArmorStand(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaArmorStand(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaArmorStand armorStand ? armorStand : new CraftMetaArmorStand(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<KnowledgeBookMeta> KNOWLEDGE_BOOK_META_DATA = new ItemMetaData<>(KnowledgeBookMeta.class,
|
||||||
|
- item -> new CraftMetaKnowledgeBook(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaKnowledgeBook(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaKnowledgeBook knowledgeBook ? knowledgeBook : new CraftMetaKnowledgeBook(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<BlockStateMeta> BLOCK_STATE_META_DATA = new ItemMetaData<>(BlockStateMeta.class,
|
||||||
|
- item -> new CraftMetaBlockState(item.getComponentsPatch(), CraftItemType.minecraftToBukkit(item.getItem())),
|
||||||
|
+ (item, extras) -> new CraftMetaBlockState(item.getComponentsPatch(), CraftItemType.minecraftToBukkit(item.getItem()), extras),
|
||||||
|
(type, meta) -> new CraftMetaBlockState(meta, type.asMaterial()));
|
||||||
|
|
||||||
|
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),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaTropicalFishBucket tropicalFishBucket ? tropicalFishBucket : new CraftMetaTropicalFishBucket(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<AxolotlBucketMeta> AXOLOTL_BUCKET_META_DATA = new ItemMetaData<>(AxolotlBucketMeta.class,
|
||||||
|
- item -> new CraftMetaAxolotlBucket(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaAxolotlBucket(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaAxolotlBucket axolotlBucket ? axolotlBucket : new CraftMetaAxolotlBucket(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<CrossbowMeta> CROSSBOW_META_DATA = new ItemMetaData<>(CrossbowMeta.class,
|
||||||
|
- item -> new CraftMetaCrossbow(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaCrossbow(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaCrossbow crossbow ? crossbow : new CraftMetaCrossbow(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<SuspiciousStewMeta> SUSPICIOUS_STEW_META_DATA = new ItemMetaData<>(SuspiciousStewMeta.class,
|
||||||
|
- item -> new CraftMetaSuspiciousStew(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaSuspiciousStew(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaSuspiciousStew suspiciousStew ? suspiciousStew : new CraftMetaSuspiciousStew(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<ItemMeta> ENTITY_TAG_META_DATA = new ItemMetaData<>(ItemMeta.class,
|
||||||
|
- item -> new CraftMetaEntityTag(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaEntityTag(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaEntityTag entityTag ? entityTag : new CraftMetaEntityTag(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<CompassMeta> COMPASS_META_DATA = new ItemMetaData<>(CompassMeta.class,
|
||||||
|
- item -> new CraftMetaCompass(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaCompass(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaCompass compass ? compass : new CraftMetaCompass(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<BundleMeta> BUNDLE_META_DATA = new ItemMetaData<>(BundleMeta.class,
|
||||||
|
- item -> new CraftMetaBundle(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaBundle(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaBundle bundle ? bundle : new CraftMetaBundle(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<MusicInstrumentMeta> MUSIC_INSTRUMENT_META_DATA = new ItemMetaData<>(MusicInstrumentMeta.class,
|
||||||
|
- item -> new CraftMetaMusicInstrument(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaMusicInstrument(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaMusicInstrument musicInstrument ? musicInstrument : new CraftMetaMusicInstrument(meta));
|
||||||
|
|
||||||
|
private static final ItemMetaData<OminousBottleMeta> OMINOUS_BOTTLE_META_DATA = new ItemMetaData<>(OminousBottleMeta.class,
|
||||||
|
- item -> new CraftMetaOminousBottle(item.getComponentsPatch()),
|
||||||
|
+ (item, extras) -> new CraftMetaOminousBottle(item.getComponentsPatch(), extras),
|
||||||
|
(type, meta) -> meta instanceof CraftMetaOminousBottle musicInstrument ? musicInstrument : new CraftMetaOminousBottle(meta));
|
||||||
|
|
||||||
|
// We use if instead of a set, since the result gets cached in CraftItemType,
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
@ -33,7 +182,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ newMeta = getItemMeta(this.handle);
|
+ newMeta = getItemMeta(this.handle);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ final java.util.Set<net.minecraft.core.component.DataComponentType<?>> extraHandledDcts = new java.util.HashSet<>(CraftMetaItem.getTopLevelHandledDcts(oldMeta.getClass()));
|
+ final java.util.Set<net.minecraft.core.component.DataComponentType<?>> extraHandledDcts = new java.util.HashSet<>(CraftMetaItem.getTopLevelHandledDcts(oldMeta.getClass()));
|
||||||
+ newMeta = getItemMeta(this.handle, CraftItemStack.getType(this.handle), extraHandledDcts);
|
+ newMeta = getItemMeta(this.handle, CraftItemType.minecraftToBukkitNew(this.handle.getItem()), extraHandledDcts);
|
||||||
+ }
|
+ }
|
||||||
+ this.setItemMeta(newMeta);
|
+ this.setItemMeta(newMeta);
|
||||||
+ }
|
+ }
|
||||||
|
@ -43,141 +192,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
final CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator();
|
final CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator();
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||||
}
|
}
|
||||||
public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, Material material) {
|
public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, org.bukkit.inventory.ItemType metaForType) {
|
||||||
// Paper end
|
// Paper end
|
||||||
+ // Paper start - handled tags on type change
|
+ // Paper start - handled tags on type change
|
||||||
+ return getItemMeta(item, material, null);
|
+ return getItemMeta(item, metaForType, null);
|
||||||
+ }
|
+ }
|
||||||
+ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, Material material, final java.util.Set<net.minecraft.core.component.DataComponentType<?>> extraHandledDcts) {
|
+ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, org.bukkit.inventory.ItemType metaForType, final java.util.Set<net.minecraft.core.component.DataComponentType<?>> extraHandledDcts) {
|
||||||
+ // Paper end - handled tags on type change
|
+ // Paper end - handled tags on type change
|
||||||
if (!CraftItemStack.hasItemMeta(item)) {
|
if (!CraftItemStack.hasItemMeta(item)) {
|
||||||
return CraftItemFactory.instance().getItemMeta(material); // Paper
|
return CraftItemFactory.instance().getItemMeta(CraftItemStack.getType(item));
|
||||||
}
|
|
||||||
switch (material) { // Paper
|
|
||||||
case WRITTEN_BOOK:
|
|
||||||
- return new CraftMetaBookSigned(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaBookSigned(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case WRITABLE_BOOK:
|
|
||||||
- return new CraftMetaBook(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaBook(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case CREEPER_HEAD:
|
|
||||||
case CREEPER_WALL_HEAD:
|
|
||||||
case DRAGON_HEAD:
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case WITHER_SKELETON_WALL_SKULL:
|
|
||||||
case ZOMBIE_HEAD:
|
|
||||||
case ZOMBIE_WALL_HEAD:
|
|
||||||
- return new CraftMetaSkull(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaSkull(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case CHAINMAIL_HELMET:
|
|
||||||
case CHAINMAIL_CHESTPLATE:
|
|
||||||
case CHAINMAIL_LEGGINGS:
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case NETHERITE_LEGGINGS:
|
|
||||||
case NETHERITE_BOOTS:
|
|
||||||
case TURTLE_HELMET:
|
|
||||||
- return new CraftMetaArmor(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaArmor(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case LEATHER_HELMET:
|
|
||||||
case LEATHER_CHESTPLATE:
|
|
||||||
case LEATHER_LEGGINGS:
|
|
||||||
case LEATHER_BOOTS:
|
|
||||||
case WOLF_ARMOR:
|
|
||||||
- return new CraftMetaColorableArmor(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaColorableArmor(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case LEATHER_HORSE_ARMOR:
|
|
||||||
- return new CraftMetaLeatherArmor(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaLeatherArmor(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case POTION:
|
|
||||||
case SPLASH_POTION:
|
|
||||||
case LINGERING_POTION:
|
|
||||||
case TIPPED_ARROW:
|
|
||||||
- return new CraftMetaPotion(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaPotion(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case FILLED_MAP:
|
|
||||||
- return new CraftMetaMap(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaMap(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case FIREWORK_ROCKET:
|
|
||||||
- return new CraftMetaFirework(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaFirework(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case FIREWORK_STAR:
|
|
||||||
- return new CraftMetaCharge(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaCharge(item.getComponentsPatch(), extraHandledDcts); // Paper;
|
|
||||||
case ENCHANTED_BOOK:
|
|
||||||
- return new CraftMetaEnchantedBook(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaEnchantedBook(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case BLACK_BANNER:
|
|
||||||
case BLACK_WALL_BANNER:
|
|
||||||
case BLUE_BANNER:
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case WHITE_WALL_BANNER:
|
|
||||||
case YELLOW_BANNER:
|
|
||||||
case YELLOW_WALL_BANNER:
|
|
||||||
- return new CraftMetaBanner(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaBanner(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case ARMADILLO_SPAWN_EGG:
|
|
||||||
case ALLAY_SPAWN_EGG:
|
|
||||||
case AXOLOTL_SPAWN_EGG:
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case ZOMBIE_SPAWN_EGG:
|
|
||||||
case ZOMBIE_VILLAGER_SPAWN_EGG:
|
|
||||||
case ZOMBIFIED_PIGLIN_SPAWN_EGG:
|
|
||||||
- return new CraftMetaSpawnEgg(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaSpawnEgg(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case ARMOR_STAND:
|
|
||||||
- return new CraftMetaArmorStand(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaArmorStand(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case KNOWLEDGE_BOOK:
|
|
||||||
- return new CraftMetaKnowledgeBook(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaKnowledgeBook(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case FURNACE:
|
|
||||||
case CHEST:
|
|
||||||
case TRAPPED_CHEST:
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case CRAFTER:
|
|
||||||
case TRIAL_SPAWNER:
|
|
||||||
case VAULT:
|
|
||||||
- return new CraftMetaBlockState(item.getComponentsPatch(), CraftItemType.minecraftToBukkit(item.getItem()));
|
|
||||||
+ return new CraftMetaBlockState(item.getComponentsPatch(), CraftItemType.minecraftToBukkit(item.getItem()), extraHandledDcts); // Paper
|
|
||||||
case TROPICAL_FISH_BUCKET:
|
|
||||||
- return new CraftMetaTropicalFishBucket(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaTropicalFishBucket(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case AXOLOTL_BUCKET:
|
|
||||||
- return new CraftMetaAxolotlBucket(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaAxolotlBucket(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case CROSSBOW:
|
|
||||||
- return new CraftMetaCrossbow(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaCrossbow(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case SUSPICIOUS_STEW:
|
|
||||||
- return new CraftMetaSuspiciousStew(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaSuspiciousStew(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case COD_BUCKET:
|
|
||||||
case PUFFERFISH_BUCKET:
|
|
||||||
case SALMON_BUCKET:
|
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
|
||||||
case ITEM_FRAME:
|
|
||||||
case GLOW_ITEM_FRAME:
|
|
||||||
case PAINTING:
|
|
||||||
- return new CraftMetaEntityTag(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaEntityTag(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case COMPASS:
|
|
||||||
- return new CraftMetaCompass(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaCompass(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case BUNDLE:
|
|
||||||
- return new CraftMetaBundle(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaBundle(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case GOAT_HORN:
|
|
||||||
- return new CraftMetaMusicInstrument(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaMusicInstrument(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
case OMINOUS_BOTTLE:
|
|
||||||
- return new CraftMetaOminousBottle(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaOminousBottle(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
default:
|
|
||||||
- return new CraftMetaItem(item.getComponentsPatch());
|
|
||||||
+ return new CraftMetaItem(item.getComponentsPatch(), extraHandledDcts); // Paper
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- if (metaForType != null) { return ((CraftItemType<?>) metaForType).getItemMeta(item); } // Paper
|
||||||
|
- return ((CraftItemType<?>) CraftItemType.minecraftToBukkitNew(item.getItem())).getItemMeta(item);
|
||||||
|
+ if (metaForType != null) { return ((CraftItemType<?>) metaForType).getItemMeta(item, extraHandledDcts); } // Paper
|
||||||
|
+ return ((CraftItemType<?>) CraftItemType.minecraftToBukkitNew(item.getItem())).getItemMeta(item, extraHandledDcts); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Material getType(net.minecraft.world.item.ItemStack item) {
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
|
||||||
|
- public M getItemMeta(net.minecraft.world.item.ItemStack itemStack) {
|
||||||
|
- return this.itemMetaData.get().fromItemStack().apply(itemStack);
|
||||||
|
+ public M getItemMeta(net.minecraft.world.item.ItemStack itemStack, final java.util.Set<net.minecraft.core.component.DataComponentType<?>> extraHandledDcts) {
|
||||||
|
+ return this.itemMetaData.get().fromItemStack().apply(itemStack, extraHandledDcts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public M getItemMeta(ItemMeta itemMeta) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
||||||
|
@ -429,13 +476,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper end - improve checking handled data component types
|
+ // Paper end - improve checking handled data component types
|
||||||
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
||||||
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
||||||
|
// Paper start - don't lose unhandled tags
|
||||||
if (key.getValue().isEmpty()) {
|
if (key.getValue().isEmpty()) {
|
||||||
this.unhandledTags.remove(key.getKey());
|
this.unhandledTags.remove(key.getKey());
|
||||||
- } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
- } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
||||||
+ } else if (!handledTags.contains(key.getKey())) { // Paper - improve checking handled data component types
|
+ } else if (!handledTags.contains(key.getKey())) { // Paper - improve checking handled data component types
|
||||||
key.getValue().ifPresentOrElse((value) -> {
|
// Paper end - don't lose unhandled tags
|
||||||
|
key.getValue().ifPresent((value) -> {
|
||||||
this.unhandledTags.set((DataComponentType) key.getKey(), value);
|
this.unhandledTags.set((DataComponentType) key.getKey(), value);
|
||||||
}, () -> {
|
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit befcf86d22f9576c361bba18b2ec725e41508a65
|
Subproject commit e2160a18658bb7d19d303abd7a24605848d6912c
|
|
@ -1 +1 @@
|
||||||
Subproject commit a1d2cd1521b97cb4048f990455d78e7c9fb94e82
|
Subproject commit 6ce17264243172b5e3d14309388e131f025d90f4
|
Loading…
Reference in a new issue