Don't store removed components in multiple places (#11091)

Dieser Commit ist enthalten in:
Jake Potrebic 2024-07-16 16:39:57 -07:00 committet von GitHub
Ursprung a6ceda12c5
Commit 506f1651e5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
81 geänderte Dateien mit 65 neuen und 117 gelöschten Zeilen

Datei anzeigen

@ -1,49 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 26 Apr 2024 21:33:20 -0700
Subject: [PATCH] Don't lose removed data components in ItemMeta
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 2cf89147025066f34c12b9956d18451487fb2799..bc5adcb7638d6672cad33ef4adf73e475bc16b7d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -198,6 +198,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return this;
}
+ // Paper start - support removing component types
+ <T> Applicator remove(DataComponentType<T> type) {
+ this.builder.remove(type);
+ return this;
+ }
+ // Paper end - support removing component types
+
DataComponentPatch build() {
return this.builder.build();
}
@@ -428,7 +435,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
- if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
+ // Paper start - don't lose unhandled tags
+ if (key.getValue().isEmpty()) {
+ this.unhandledTags.remove(key.getKey());
+ } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
+ // Paper end - don't lose unhandled tags
key.getValue().ifPresent((value) -> {
this.unhandledTags.set((DataComponentType) key.getKey(), value);
});
@@ -864,9 +875,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
for (Map.Entry<DataComponentType<?>, Optional<?>> e : this.unhandledTags.build().entrySet()) {
- e.getValue().ifPresent((value) -> {
+ e.getValue().ifPresentOrElse((value) -> {
itemTag.builder.set((DataComponentType) e.getKey(), value);
- });
+ }, () -> itemTag.remove(e.getKey()));
}
for (DataComponentType<?> removed : this.removedTags) {

Datei anzeigen

@ -33,10 +33,10 @@ index 73fe41322e0349ad1d46a760f621b6c91112e90e..19af55ec2bf62b70bd3be44f499b32f5
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0ddd5531755 100644
index 2cf89147025066f34c12b9956d18451487fb2799..078b75f027b99a8a2a6a3ee19d087acc03eefe12 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -252,6 +252,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -245,6 +245,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
static final ItemMetaKeyType<Unit> HIDE_ADDITIONAL_TOOLTIP = new ItemMetaKeyType(DataComponents.HIDE_ADDITIONAL_TOOLTIP);
@Specific(Specific.To.NBT)
static final ItemMetaKeyType<CustomData> CUSTOM_DATA = new ItemMetaKeyType<>(DataComponents.CUSTOM_DATA);
@ -49,7 +49,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
// We store the raw original JSON representation of all text data. See SPIGOT-5063, SPIGOT-5656, SPIGOT-5304
private Component displayName;
@@ -334,6 +340,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -327,6 +333,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.customTag = meta.customTag;
this.version = meta.version;
@ -60,7 +60,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
}
CraftMetaItem(DataComponentPatch tag) {
@@ -432,6 +442,20 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -425,6 +435,20 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.customTag = null;
}
});
@ -81,7 +81,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
@@ -631,7 +655,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -620,7 +644,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
try {
CompoundTag unhandledTag = NbtIo.readCompressed(buf, NbtAccounter.unlimitedHeap());
DataComponentPatch unhandledPatch = DataComponentPatch.CODEC.parse(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), unhandledTag).result().get();
@ -98,7 +98,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
for (Entry<DataComponentType<?>, Optional<?>> entry : unhandledPatch.entrySet()) {
// Move removed unhandled tags to dedicated removedTags
@@ -874,6 +906,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -863,6 +895,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
itemTag.put(CraftMetaItem.MAX_DAMAGE, this.maxDamage);
}
@ -112,9 +112,9 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
+ // Paper end
+
for (Map.Entry<DataComponentType<?>, Optional<?>> e : this.unhandledTags.build().entrySet()) {
e.getValue().ifPresentOrElse((value) -> {
e.getValue().ifPresent((value) -> {
itemTag.builder.set((DataComponentType) e.getKey(), value);
@@ -962,7 +1003,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -951,7 +992,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Overridden
boolean isEmpty() {
@ -123,7 +123,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
}
// Paper start
@@ -1632,6 +1673,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1621,6 +1662,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
&& (this.hasJukeboxPlayable() ? that.hasJukeboxPlayable() && this.jukebox.equals(that.jukebox) : !that.hasJukeboxPlayable())
&& (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage())
&& (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage())
@ -132,7 +132,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
&& (this.version == that.version);
}
@@ -1677,6 +1720,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1666,6 +1709,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
hash = 61 * hash + (this.hasDamage() ? this.damage : 0);
hash = 61 * hash + (this.hasMaxDamage() ? 1231 : 1237);
hash = 61 * hash + (this.hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0);
@ -141,7 +141,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
hash = 61 * hash + this.version;
return hash;
}
@@ -1721,6 +1766,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1710,6 +1755,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
clone.damage = this.damage;
clone.maxDamage = this.maxDamage;
clone.version = this.version;
@ -156,7 +156,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
return clone;
} catch (CloneNotSupportedException e) {
throw new Error(e);
@@ -1838,6 +1891,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1827,6 +1880,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
}
@ -173,7 +173,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
if (!this.unhandledTags.isEmpty()) {
Tag unhandled = DataComponentPatch.CODEC.encodeStart(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), this.unhandledTags.build()).getOrThrow(IllegalStateException::new);
try {
@@ -1848,6 +1911,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1837,6 +1900,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
@ -188,7 +188,7 @@ index bc5adcb7638d6672cad33ef4adf73e475bc16b7d..d29b8c6851aad227eb8f12012903e0dd
if (!this.removedTags.isEmpty()) {
RegistryAccess registryAccess = CraftRegistry.getMinecraftRegistry();
@@ -2001,6 +2072,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1990,6 +2061,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
CraftMetaItem.MAX_DAMAGE.TYPE,
CraftMetaItem.CUSTOM_DATA.TYPE,
CraftMetaItem.ATTRIBUTES.TYPE,

Datei anzeigen

@ -451,10 +451,10 @@ index 8c1d2d0521da52f9a1262f5433da21700b9b0454..9600b23666668d7d581e2920a4e03e59
getOrEmpty(tag, CraftMetaFirework.FIREWORKS).ifPresent((fireworks) -> {
this.power = fireworks.flightDuration();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index d29b8c6851aad227eb8f12012903e0ddd5531755..58da8cb19a8444c634cbc1f39e93503ca8e2ecab 100644
index 078b75f027b99a8a2a6a3ee19d087acc03eefe12..1903a6948242e2dc40302a0acb9171fc3cc3000e 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -346,7 +346,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -339,7 +339,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper end
}
@ -463,7 +463,7 @@ index d29b8c6851aad227eb8f12012903e0ddd5531755..58da8cb19a8444c634cbc1f39e93503c
CraftMetaItem.getOrEmpty(tag, CraftMetaItem.NAME).ifPresent((component) -> {
this.displayName = component;
});
@@ -457,12 +457,19 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -450,9 +450,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
});
// Paper end - fix ItemFlags
@ -476,15 +476,12 @@ index d29b8c6851aad227eb8f12012903e0ddd5531755..58da8cb19a8444c634cbc1f39e93503c
+ // Paper end - improve checking handled data component types
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
// Paper start - don't lose unhandled tags
if (key.getValue().isEmpty()) {
this.unhandledTags.remove(key.getKey());
- } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
+ } else if (!handledTags.contains(key.getKey())) { // Paper - improve checking handled data component types
// Paper end - don't lose unhandled tags
- if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
+ if (!handledTags.contains(key.getKey())) { // Paper - improve checking handled data component types
key.getValue().ifPresent((value) -> {
this.unhandledTags.set((DataComponentType) key.getKey(), value);
@@ -2047,67 +2054,75 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
});
@@ -2036,67 +2043,75 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.version = version;
}

Datei anzeigen

@ -795,7 +795,7 @@ index 9600b23666668d7d581e2920a4e03e59cc2339fb..0eceacbb096481d3bd31f5f99e964c88
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad3995dd8018 100644
index 1903a6948242e2dc40302a0acb9171fc3cc3000e..a9acbb181dd72238b63fb08fda1b3bc0d246e36e 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -182,9 +182,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -811,7 +811,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
<T> Applicator put(ItemMetaKeyType<T> key, T value) {
this.builder.set(key.TYPE, value);
@@ -278,7 +279,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -271,7 +272,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
private CraftFoodComponent food;
private CraftToolComponent tool;
private CraftJukeboxComponent jukebox;
@ -820,7 +820,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
private Integer maxDamage;
private static final Set<DataComponentType> HANDLED_TAGS = Sets.newHashSet();
@@ -310,7 +311,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -303,7 +304,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.enchantments = new EnchantmentMap(meta.enchantments); // Paper
}
@ -829,7 +829,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
this.attributeModifiers = LinkedHashMultimap.create(meta.attributeModifiers);
}
@@ -347,6 +348,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -340,6 +341,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
CraftMetaItem(DataComponentPatch tag, Set<DataComponentType<?>> extraHandledTags) { // Paper - improve handled tags on type changes
@ -841,7 +841,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
CraftMetaItem.getOrEmpty(tag, CraftMetaItem.NAME).ifPresent((component) -> {
this.displayName = component;
});
@@ -802,7 +808,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -791,7 +797,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Map<?, ?> mods = SerializableMeta.getObject(Map.class, map, key.BUKKIT, true);
Multimap<Attribute, AttributeModifier> result = LinkedHashMultimap.create();
if (mods == null) {
@ -850,7 +850,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
}
for (Object obj : mods.keySet()) {
@@ -905,7 +911,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -894,7 +900,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
itemTag.put(CraftMetaItem.JUKEBOX_PLAYABLE, this.jukebox.getHandle());
}
@ -859,7 +859,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
itemTag.put(CraftMetaItem.DAMAGE, this.damage);
}
@@ -970,10 +976,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -959,10 +965,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
void applyModifiers(Multimap<Attribute, AttributeModifier> modifiers, CraftMetaItem.Applicator tag) {
@ -872,7 +872,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
return;
}
@@ -1010,7 +1014,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -999,7 +1003,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Overridden
boolean isEmpty() {
@ -881,7 +881,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
}
// Paper start
@@ -1106,6 +1110,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1095,6 +1099,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public void lore(final List<? extends net.kyori.adventure.text.Component> lore) {
@ -889,7 +889,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null;
}
// Paper end
@@ -1164,7 +1169,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1153,7 +1158,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public void removeEnchantments() {
if (this.hasEnchants()) {
@ -898,7 +898,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
}
}
@@ -1230,6 +1235,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1219,6 +1224,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper end
@Override
public void setLore(List<String> lore) {
@ -906,7 +906,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
if (lore == null || lore.isEmpty()) {
this.lore = null;
} else {
@@ -1245,6 +1251,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1234,6 +1240,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper start
@Override
public void setLoreComponents(List<net.md_5.bungee.api.chat.BaseComponent[]> lore) {
@ -914,7 +914,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
if (lore == null) {
this.lore = null;
} else {
@@ -1386,7 +1393,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1375,7 +1382,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public FoodComponent getFood() {
@ -923,7 +923,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
}
@Override
@@ -1442,7 +1449,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1431,7 +1438,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(@Nullable EquipmentSlot slot) {
@ -932,7 +932,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
SetMultimap<Attribute, AttributeModifier> result = LinkedHashMultimap.create();
for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) {
if (entry.getValue().getSlot() == null || entry.getValue().getSlot() == slot) {
@@ -1455,6 +1462,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1444,6 +1451,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public Collection<AttributeModifier> getAttributeModifiers(@Nonnull Attribute attribute) {
Preconditions.checkNotNull(attribute, "Attribute cannot be null");
@ -940,7 +940,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
return this.attributeModifiers.containsKey(attribute) ? ImmutableList.copyOf(this.attributeModifiers.get(attribute)) : null;
}
@@ -1462,22 +1470,33 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1451,22 +1459,33 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
public boolean addAttributeModifier(@Nonnull Attribute attribute, @Nonnull AttributeModifier modifier) {
Preconditions.checkNotNull(attribute, "Attribute cannot be null");
Preconditions.checkNotNull(modifier, "AttributeModifier cannot be null");
@ -978,7 +978,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
Iterator<Map.Entry<Attribute, AttributeModifier>> iterator = attributeModifiers.entries().iterator();
while (iterator.hasNext()) {
@@ -1487,6 +1506,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1476,6 +1495,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
iterator.remove();
continue;
}
@ -986,7 +986,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
this.attributeModifiers.put(next.getKey(), next.getValue());
}
}
@@ -1494,13 +1514,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1483,13 +1503,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public boolean removeAttributeModifier(@Nonnull Attribute attribute) {
Preconditions.checkNotNull(attribute, "Attribute cannot be null");
@ -1002,7 +1002,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
int removed = 0;
Iterator<Map.Entry<Attribute, AttributeModifier>> iter = this.attributeModifiers.entries().iterator();
@@ -1520,7 +1540,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1509,7 +1529,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
public boolean removeAttributeModifier(@Nonnull Attribute attribute, @Nonnull AttributeModifier modifier) {
Preconditions.checkNotNull(attribute, "Attribute cannot be null");
Preconditions.checkNotNull(modifier, "AttributeModifier cannot be null");
@ -1011,7 +1011,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
int removed = 0;
Iterator<Map.Entry<Attribute, AttributeModifier>> iter = this.attributeModifiers.entries().iterator();
@@ -1542,7 +1562,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1531,7 +1551,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public String getAsString() {
@ -1020,7 +1020,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
this.applyToItem(tag);
DataComponentPatch patch = tag.build();
Tag nbt = DataComponentPatch.CODEC.encodeStart(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), patch).getOrThrow();
@@ -1551,7 +1571,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1540,7 +1560,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public String getAsComponentString() {
@ -1029,7 +1029,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
this.applyToItem(tag);
DataComponentPatch patch = tag.build();
@@ -1591,6 +1611,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1580,6 +1600,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (first == null || second == null) {
return false;
}
@ -1037,7 +1037,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
for (Map.Entry<Attribute, AttributeModifier> entry : first.entries()) {
if (!second.containsEntry(entry.getKey(), entry.getValue())) {
return false;
@@ -1606,19 +1627,33 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1595,19 +1616,33 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public boolean hasDamage() {
@ -1073,7 +1073,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
@Override
public boolean hasMaxDamage() {
return this.maxDamage != null;
@@ -1632,6 +1667,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1621,6 +1656,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public void setMaxDamage(Integer maxDamage) {
@ -1081,7 +1081,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
this.maxDamage = maxDamage;
}
@@ -1663,7 +1699,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1652,7 +1688,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
&& (this.hasCustomModelData() ? that.hasCustomModelData() && this.customModelData.equals(that.customModelData) : !that.hasCustomModelData())
&& (this.hasBlockData() ? that.hasBlockData() && this.blockData.equals(that.blockData) : !that.hasBlockData())
&& (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost())
@ -1090,7 +1090,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
&& (this.unhandledTags.equals(that.unhandledTags))
&& (this.removedTags.equals(that.removedTags))
&& (Objects.equals(this.customTag, that.customTag))
@@ -1678,7 +1714,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1667,7 +1703,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
&& (this.hasFood() ? that.hasFood() && this.food.equals(that.food) : !that.hasFood())
&& (this.hasTool() ? that.hasTool() && this.tool.equals(that.tool) : !that.hasTool())
&& (this.hasJukeboxPlayable() ? that.hasJukeboxPlayable() && this.jukebox.equals(that.jukebox) : !that.hasJukeboxPlayable())
@ -1099,7 +1099,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
&& (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage())
&& (this.canPlaceOnPredicates != null ? that.canPlaceOnPredicates != null && this.canPlaceOnPredicates.equals(that.canPlaceOnPredicates) : that.canPlaceOnPredicates == null) // Paper
&& (this.canBreakPredicates != null ? that.canBreakPredicates != null && this.canBreakPredicates.equals(that.canBreakPredicates) : that.canBreakPredicates == null) // Paper
@@ -1724,9 +1760,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1713,9 +1749,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
hash = 61 * hash + (this.hasFood() ? this.food.hashCode() : 0);
hash = 61 * hash + (this.hasTool() ? this.tool.hashCode() : 0);
hash = 61 * hash + (this.hasJukeboxPlayable() ? this.jukebox.hashCode() : 0);
@ -1112,7 +1112,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
hash = 61 * hash + (this.canPlaceOnPredicates != null ? this.canPlaceOnPredicates.hashCode() : 0); // Paper
hash = 61 * hash + (this.canBreakPredicates != null ? this.canBreakPredicates.hashCode() : 0); // Paper
hash = 61 * hash + this.version;
@@ -1746,7 +1782,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1735,7 +1771,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (this.enchantments != null) {
clone.enchantments = new EnchantmentMap(this.enchantments); // Paper
}
@ -1121,7 +1121,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
}
if (this.customTag != null) {
@@ -1874,7 +1910,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1863,7 +1899,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
builder.put(CraftMetaItem.JUKEBOX_PLAYABLE.BUKKIT, this.jukebox);
}
@ -1130,7 +1130,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
builder.put(CraftMetaItem.DAMAGE.BUKKIT, this.damage);
}
@@ -1975,7 +2011,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1964,7 +2000,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
}
static void serializeModifiers(Multimap<Attribute, AttributeModifier> modifiers, ImmutableMap.Builder<String, Object> builder, ItemMetaKey key) {
@ -1139,7 +1139,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
return;
}
@@ -2057,7 +2093,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -2046,7 +2082,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper start - improve checking handled tags
@org.jetbrains.annotations.VisibleForTesting
public static final Map<Class<? extends CraftMetaItem>, Set<DataComponentType<?>>> HANDLED_DCTS_PER_TYPE = new HashMap<>();
@ -1148,7 +1148,7 @@ index 58da8cb19a8444c634cbc1f39e93503ca8e2ecab..20d0ca163242bb58369f0709f452ad39
CraftMetaItem.NAME.TYPE,
CraftMetaItem.ITEM_NAME.TYPE,
CraftMetaItem.LORE.TYPE,
@@ -2125,7 +2161,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -2114,7 +2150,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper end - improve checking handled data component types
protected static <T> Optional<? extends T> getOrEmpty(DataComponentPatch tag, ItemMetaKeyType<T> type) {

Datei anzeigen

@ -52,10 +52,10 @@ index 9d74577af071954e1e37201a96368c1360076209..eafa54c870c3e2aef30c3f9f96f51660
throw new IllegalArgumentException("Not implemented. This is a bug");
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 20d0ca163242bb58369f0709f452ad3995dd8018..1ea7597b5e0f38789a9f8bdf83c3ac35ae19164f 100644
index a9acbb181dd72238b63fb08fda1b3bc0d246e36e..d87bfdda1f06a94e97465c105d28989e1d64e1e0 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -1452,7 +1452,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1441,7 +1441,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (this.attributeModifiers == null) return LinkedHashMultimap.create(); // Paper - don't change the components
SetMultimap<Attribute, AttributeModifier> result = LinkedHashMultimap.create();
for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) {
@ -64,7 +64,7 @@ index 20d0ca163242bb58369f0709f452ad3995dd8018..1ea7597b5e0f38789a9f8bdf83c3ac35
result.put(entry.getKey(), entry.getValue());
}
}
@@ -1526,9 +1526,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@@ -1515,9 +1515,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
while (iter.hasNext()) {
Map.Entry<Attribute, AttributeModifier> entry = iter.next();

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] disable forced empty world ticks
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 9bebb4648b6490abb9942f6406ad4f96d4bf799f..e90199531c6c2975644e1223502bcecb4469220f 100644
index bb3826481d6165991f4201ed39d56fa5824a841f..2e30f8a12391222e612a9c1bf56e93625f52a8dc 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -710,7 +710,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

Datei anzeigen

@ -13,7 +13,7 @@ custom renderers are in use, defaulting to the much simpler Vanilla system.
Additionally, numerous issues to player position tracking on maps has been fixed.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index e90199531c6c2975644e1223502bcecb4469220f..aa5c2ccf2a49d0f29c17babcf853b750f0b37a4f 100644
index 2e30f8a12391222e612a9c1bf56e93625f52a8dc..162671f8e370c84832b18697a1ef787981e1632d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2518,6 +2518,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

Datei anzeigen

@ -17,7 +17,7 @@ Adds villagers as separate config
public net.minecraft.world.entity.Entity isInsidePortal
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index aa5c2ccf2a49d0f29c17babcf853b750f0b37a4f..70fbce91ef8f132fec4ab778f465a948c80d0ce8 100644
index 162671f8e370c84832b18697a1ef787981e1632d..8b6a1a80a3bf95e7f17c6b64d0949d6732352f0c 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2,7 +2,6 @@ package net.minecraft.server.level;

Datei anzeigen

@ -37,7 +37,7 @@ index d843bc04ae93d11d7820cab5ed18617193568f0d..152cd6b1671785b495caeb7e535f58df
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 67eb2fb32de3555b3afb4b4b7a3a47a164158ac8..bafeda818e02eb3de9dc78f62106a0d3e95d476b 100644
index d2cb358c340bcf7532fd25eccdd33c6945d16de4..2211c054f55e962082eac82aedf5ca625e5b25f2 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -439,7 +439,19 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon

Datei anzeigen

@ -1104,7 +1104,7 @@ index 183b2191fa1c1b27adedf39593e1b5a223fb1279..8ead66c134688b11dca15f6509147e72
private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buf) {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 70fbce91ef8f132fec4ab778f465a948c80d0ce8..b1e96f74ca3c9607795044e5fc746d9465310fdb 100644
index 8b6a1a80a3bf95e7f17c6b64d0949d6732352f0c..6a844382882a69bfc690b956fa8d59c2d0ea0bd3 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -515,7 +515,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

Datei anzeigen

@ -2009,7 +2009,7 @@ index 0000000000000000000000000000000000000000..33cd90c30c22200a4e1ae64f40a0bf78
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b1e96f74ca3c9607795044e5fc746d9465310fdb..2a08dfbda588bd6282d78b35bf33a0802b178a70 100644
index 6a844382882a69bfc690b956fa8d59c2d0ea0bd3..a994456adb0034c0662151f4ae28c1c06f91333e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -228,6 +228,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

Datei anzeigen

@ -37,7 +37,7 @@ index 152cd6b1671785b495caeb7e535f58df864ce24c..344966d3deb640eb99bc9c9e318e6e67
}
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index bafeda818e02eb3de9dc78f62106a0d3e95d476b..64ed296cfbe7e5d27286b8cee70454fd1d99ebb0 100644
index 2211c054f55e962082eac82aedf5ca625e5b25f2..61e222fb129c5733411ce95aaa5f035dbd95b01a 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -445,7 +445,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon

Datei anzeigen

@ -76,7 +76,7 @@ index d0d36a57ec4896bcb74970f8fb24d8f3e17db133..e2c24813f59c2fd075c740ac1842a38f
});
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 9c9107add605c09445cf795f4c850b080b4f995d..4b601c066b94fddd7d878677098bca0d3ae2e5a3 100644
index bee76ffe45e97c9c03430cf5a52d279421bc6536..e4cdbbf8a37f1363711ecd23f9c0eadcc95f7209 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1223,7 +1223,26 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

Datei anzeigen

@ -24,7 +24,7 @@ index 61e222fb129c5733411ce95aaa5f035dbd95b01a..3575fe6f57457ab865a29d20836512f6
// CraftBukkit start - modelled on below
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 4b601c066b94fddd7d878677098bca0d3ae2e5a3..db40701c22d7526b696d503df1e198a70f5beaa9 100644
index e4cdbbf8a37f1363711ecd23f9c0eadcc95f7209..9b463cd43bcf763faab04012137695a575f16729 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1354,7 +1354,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.