d1a72eac31
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: 1fc1020a PR-1049: Add MenuType API 8ae2e3be PR-1055: Expand riptiding API cac68bfb SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor 7004fcf2 SPIGOT-7886: Fix mistake in AttributeModifier UUID shim 1ac7f950 PR-1054: Add FireworkMeta#hasPower 4cfb565f SPIGOT-7873: Add powered state for skulls CraftBukkit Changes: bbb30e7a8 SPIGOT-7894: NPE when sending tile entity update ba21e9472 SPIGOT-7895: PlayerItemBreakEvent not firing 0fb24bbe0 SPIGOT-7875: Fix PlayerItemConsumeEvent cancellation causing client-side desync 815066449 SPIGOT-7891: Can't remove second ingredient of MerchantRecipe 45c206f2c PR-1458: Add MenuType API 19c8ef9ae SPIGOT-7867: Merchant instanceof AbstractVillager always returns false 4e006d28f PR-1468: Expand riptiding API bd8aded7d Ignore checks in CraftPlayerProfile for ResolvableProfile used in profile components 8679620b5 SPIGOT-7889: Fix tool component deserialisation without speed and/or correct-for-drops 8d5222691 SPIGOT-7882, PR-1467: Fix conversion of name in Profile Component to empty if it is missing 63f91669a SPIGOT-7887: Remove duplicate ProjectileHitEvent for fireballs 7070de8c8 SPIGOT-7878: Server#getLootTable does not return null on invalid loot table 060ee6cae SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies 7ccb86cc0 PR-1465: Add FireworkMeta#hasPower 804ad6491 SPIGOT-7873: Add powered state for skulls f9610cdcb Improve minecart movement Spigot Changes: a759b629 Rebuild patches Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
143 Zeilen
7.5 KiB
Diff
143 Zeilen
7.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: TonytheMacaroni <tonythemacaroni123@gmail.com>
|
|
Date: Thu, 9 Nov 2023 20:34:44 -0500
|
|
Subject: [PATCH] Add UUID attribute modifier API
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
|
index 52439f4b959c74027eb191a3af960c70beb978e8..a2c057d92ea34368c7efc538b6e5b15ef342c54e 100644
|
|
--- a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
|
+++ b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
|
@@ -5,6 +5,7 @@ import org.bukkit.attribute.Attribute;
|
|
import org.bukkit.attribute.AttributeModifier;
|
|
import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
|
|
|
|
+import java.util.UUID;
|
|
import java.util.Collection;
|
|
|
|
public class UnmodifiableAttributeInstance extends CraftAttributeInstance {
|
|
@@ -18,6 +19,11 @@ public class UnmodifiableAttributeInstance extends CraftAttributeInstance {
|
|
throw new UnsupportedOperationException("Cannot modify default attributes");
|
|
}
|
|
|
|
+ @Override
|
|
+ public void removeModifier(UUID uuid) {
|
|
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
|
+ }
|
|
+
|
|
@Override
|
|
public void addModifier(AttributeModifier modifier) {
|
|
throw new UnsupportedOperationException("Cannot modify default attributes");
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/AttributeMappings.java b/src/main/java/org/bukkit/craftbukkit/attribute/AttributeMappings.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..ce23ac9bcf5b043a07130da39cc8804f0d0be1e5
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/AttributeMappings.java
|
|
@@ -0,0 +1,68 @@
|
|
+package org.bukkit.craftbukkit.attribute;
|
|
+
|
|
+import java.util.HashMap;
|
|
+import java.util.Map;
|
|
+import java.util.UUID;
|
|
+import org.bukkit.NamespacedKey;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+final class AttributeMappings {
|
|
+ private static final Map<UUID, NamespacedKey> ATTRIBUTE_MODIFIER_IDS = new HashMap<>();
|
|
+
|
|
+ static {
|
|
+ add(-4483571535397864886L, -5989644940537681742L, "armor.body");
|
|
+ add(8144722948526719024L, -7778190119041365872L, "effect.slowness");
|
|
+ add(6967552254039378640L, -9116175396973475259L, "enchantment.aqua_affinity");
|
|
+ add(5279725409867744698L, -5150363631200102632L, "attacking");
|
|
+ add(148071211714102867L, -7685811609035173472L, "attacking");
|
|
+ add(6196088217904236654L, -7493791321850887290L, "effect.minining_fatigue");
|
|
+ add(-5084161844451524480L, -8859020046251006329L, "enchantment.soul_speed");
|
|
+ add(-7907339078496465106L, -8112074600724210224L, "enchantment.swift_sneak");
|
|
+ add(6688265815086220243L, -6545541163342161890L, "drinking");
|
|
+ add(8315164243412860989L, -6631520853640075966L, "creative_mode_block_range");
|
|
+ add(4389663563256579765L, -4827163546944004714L, "enchantment.efficiency");
|
|
+ add(6732612758648800940L, -5145707699103688244L, "effect.health_boost");
|
|
+ add(9079981369298536661L, -6728494925450710401L, "covered");
|
|
+ add(-1521481167610687786L, -8630419745734927691L, "effect.absorption");
|
|
+ add(-7473408062188862076L, -5872005994337939597L, "creative_mode_entity_range");
|
|
+ add(-3721396875562958315L, -5317020504214661337L, "effect.unluck");
|
|
+ add(-2861585646493481178L, -6113244764726669811L, "armor.leggings");
|
|
+ add(6718535547217657911L, -5386630269401489641L, "enchantment.sweeping_edge");
|
|
+ add(-7949229004988660584L, -7828611303000832459L, "effect.speed");
|
|
+ add(-8650171790042118250L, -5749650997644763080L, "enchantment.soul_speed");
|
|
+ add(551224288813600377L, -8734740027710371860L, "enchantment.respiration");
|
|
+ add(-7046399332347654691L, -6723081531683397260L, "suffocating");
|
|
+ add(7361814797886573596L, -8641397326606817395L, "sprinting");
|
|
+ add(-6972338111383059132L, -8978659762232839026L, "armor.chestplate");
|
|
+ add(-5371971015925809039L, -6062243582569928137L, "enchantment.fire_protection");
|
|
+ add(7245570952092733273L, -8449101711440750679L, "effect.strength");
|
|
+ add(-422425648963762075L, -5756800103171642205L, "base_attack_speed");
|
|
+ add(-4607081316629330256L, -7008565754814018370L, "effect.jump_boost");
|
|
+ add(271280981090454338L, -8746077033958322898L, "effect.luck");
|
|
+ add(2211131075215181206L, -5513857709499300658L, "powder_snow");
|
|
+ add(-8908768238899017377L, -8313820693701227669L, "armor.boots");
|
|
+ add(-5797418877589107702L, -6181652684028920077L, "effect.haste");
|
|
+ add(3086076556416732775L, -5150312587563650736L, "armor.helmet");
|
|
+ add(-5082757096938257406L, -4891139119377885130L, "baby");
|
|
+ add(2478452629826324956L, -7247530463494186011L, "effect.weakness");
|
|
+ add(4659420831966187055L, -5191473055587376048L, "enchantment.blast_protection");
|
|
+ add(7301951777949303281L, -6753860660653972126L, "evil");
|
|
+ add(8533189226688352746L, -8254757081029716377L, "baby");
|
|
+ add(1286946037536540352L, -5768092872487507967L, "enchantment.depth_strider");
|
|
+ add(-3801225194067177672L, -6586624321849018929L, "base_attack_damage");
|
|
+ }
|
|
+
|
|
+ public static @NotNull NamespacedKey uuidToKey(final UUID uuid) {
|
|
+ final NamespacedKey key = ATTRIBUTE_MODIFIER_IDS.get(uuid);
|
|
+ if (key != null) {
|
|
+ return key;
|
|
+ } else {
|
|
+ return NamespacedKey.minecraft(uuid.toString());
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private static void add(final long msb, final long lsb, final String id) {
|
|
+ final UUID uuid = new UUID(msb, lsb);
|
|
+ ATTRIBUTE_MODIFIER_IDS.put(uuid, NamespacedKey.minecraft(id));
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
|
|
index cd6a492f56b3dee5985c068e20009b6c833e143b..34b9d79fd1a4aa7395b3383fa721f5689494aa12 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
|
|
@@ -45,6 +45,33 @@ public class CraftAttributeInstance implements AttributeInstance {
|
|
return result;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public AttributeModifier getModifier(final net.kyori.adventure.key.Key key) {
|
|
+ Preconditions.checkArgument(key != null, "Key cannot be null");
|
|
+ net.minecraft.world.entity.ai.attributes.AttributeModifier modifier = this.handle.getModifier(io.papermc.paper.adventure.PaperAdventure.asVanilla(key));
|
|
+ return modifier == null ? null : CraftAttributeInstance.convert(modifier);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void removeModifier(final net.kyori.adventure.key.Key key) {
|
|
+ Preconditions.checkArgument(key != null, "Key cannot be null");
|
|
+ this.handle.removeModifier(io.papermc.paper.adventure.PaperAdventure.asVanilla(key));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public AttributeModifier getModifier(java.util.UUID uuid) {
|
|
+ Preconditions.checkArgument(uuid != null, "UUID cannot be null");
|
|
+ return this.getModifier(AttributeMappings.uuidToKey(uuid));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void removeModifier(java.util.UUID uuid) {
|
|
+ Preconditions.checkArgument(uuid != null, "UUID cannot be null");
|
|
+ this.removeModifier(AttributeMappings.uuidToKey(uuid));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public void addModifier(AttributeModifier modifier) {
|
|
Preconditions.checkArgument(modifier != null, "modifier");
|