Clear firework item properly (#10793)

This commit is contained in:
Lulu13022002 2024-05-26 19:57:38 +02:00 committed by GitHub
parent a7ae966530
commit ca50b87947
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 15 deletions

View file

@ -147,7 +147,7 @@ index 91c2d0b40d3fca86938cd454e1415a4eea3df7c7..de4fb2654c7895cfd83ad694455ee56c
+ // Paper end - More projectile API + // Paper end - More projectile API
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
index 98f46fadd60ea688fefa8d83dbd6fe9b61b6a96f..d4e0170694409e674d488f913e61c205f6483712 100644 index 98f46fadd60ea688fefa8d83dbd6fe9b61b6a96f..0cc1cdf91deb07ebb437ef5e61d149b2c109877f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
@@ -60,20 +60,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr @@ -60,20 +60,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
@ -168,7 +168,7 @@ index 98f46fadd60ea688fefa8d83dbd6fe9b61b6a96f..d4e0170694409e674d488f913e61c205
- } - }
- this.getHandle().projectileSource = shooter; - this.getHandle().projectileSource = shooter;
- } - }
+ // Paper - moved to AbstractProjectil + // Paper - moved to AbstractProjectile
@Override @Override
public boolean isInBlock() { public boolean isInBlock() {
@ -244,7 +244,7 @@ index e4e23a7b6d308ee476b5b8c2ad80efe4608b8346..241914415f74e0559fef59aa3f87f3e3
@Override @Override
public Vector getDirection() { public Vector getDirection() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
index c9e15a9d82dee935293b2e7e233f5b9b2d822448..fedbfbac02b73382aacc69f8a1e5a3e746c55ea2 100644 index c9e15a9d82dee935293b2e7e233f5b9b2d822448..3c31ff72f3e77ee0d9231fec5f15267c56799a7c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
@@ -15,24 +15,26 @@ import org.bukkit.inventory.meta.FireworkMeta; @@ -15,24 +15,26 @@ import org.bukkit.inventory.meta.FireworkMeta;
@ -270,7 +270,7 @@ index c9e15a9d82dee935293b2e7e233f5b9b2d822448..fedbfbac02b73382aacc69f8a1e5a3e7
- if (this.item.getType() != Material.FIREWORK_ROCKET) { - if (this.item.getType() != Material.FIREWORK_ROCKET) {
- this.item.setType(Material.FIREWORK_ROCKET); - this.item.setType(Material.FIREWORK_ROCKET);
- } - }
+// Paper start - Expose firework item directly + // Paper start - Expose firework item directly
+// ItemStack item = this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM); +// ItemStack item = this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM);
+// +//
+// if (item.isEmpty()) { +// if (item.isEmpty()) {
@ -316,7 +316,7 @@ index c9e15a9d82dee935293b2e7e233f5b9b2d822448..fedbfbac02b73382aacc69f8a1e5a3e7
+ @Override + @Override
+ public void setItem(org.bukkit.inventory.ItemStack itemStack) { + public void setItem(org.bukkit.inventory.ItemStack itemStack) {
+ FireworkMeta meta = getFireworkMeta(); + FireworkMeta meta = getFireworkMeta();
+ ItemStack nmsItem = itemStack == null ? ItemStack.EMPTY : CraftItemStack.asNMSCopy(itemStack); + ItemStack nmsItem = itemStack == null ? FireworkRocketEntity.getDefaultItem() : CraftItemStack.asNMSCopy(itemStack);
+ this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, nmsItem); + this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, nmsItem);
+ +
+ applyFireworkEffect(meta); + applyFireworkEffect(meta);

View file

@ -519,7 +519,7 @@ index f8c02fe01fd95aa5de8523c9ad452d91f5d3c16f..4447c754458e9fdead003b4044bf2bee
if (this.items == null) { if (this.items == null) {
this.items = new ArrayList<>(); this.items = new ArrayList<>();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaColorableArmor.java
index 2c9ca54267579a210d4ea192517fc0fbce8e467a..20fdd48779237d1d91d5a8f2325cd9dc824e08b5 100644 index 2c9ca54267579a210d4ea192517fc0fbce8e467a..4e423c4790d7b03c283c9a5fa94bce4a1153445e 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
@@ -22,16 +22,30 @@ public class CraftMetaColorableArmor extends CraftMetaArmor implements Colorable @@ -22,16 +22,30 @@ public class CraftMetaColorableArmor extends CraftMetaArmor implements Colorable
@ -527,7 +527,7 @@ index 2c9ca54267579a210d4ea192517fc0fbce8e467a..20fdd48779237d1d91d5a8f2325cd9dc
); );
- private Color color = DEFAULT_LEATHER_COLOR; - private Color color = DEFAULT_LEATHER_COLOR;
+ private Integer color; // Paper - keep color component consistent with vanilla (top bytes are ignored) + private Integer color; // Paper - keep color component consistent with vanilla (top byte is ignored)
CraftMetaColorableArmor(CraftMetaItem meta) { CraftMetaColorableArmor(CraftMetaItem meta) {
super(meta); super(meta);
@ -662,7 +662,7 @@ index 3f6c5cbbf63631e4b72dc43558651ea94f31ca78..da474a5b963d8e6769d120e9091e60ed
return true; return true;
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
index 8e0dd4b7a7a25a8beb27b507047bc48d8227627c..4c09c57c263b18ee2e0156cc4a49ac02a025c651 100644 index 8e0dd4b7a7a25a8beb27b507047bc48d8227627c..77489c3ffaa3a72d4cf105499a77150fca6d8526 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
@@ -55,7 +55,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { @@ -55,7 +55,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
@ -688,7 +688,7 @@ index 8e0dd4b7a7a25a8beb27b507047bc48d8227627c..4c09c57c263b18ee2e0156cc4a49ac02
for (int color : colors) { for (int color : colors) {
- effect.withColor(Color.fromRGB(color)); - effect.withColor(Color.fromRGB(color));
+ effect.withColor(Color.fromRGB(color & 0xFFFFFF)); // Paper - try to keep color component consistent with vanilla (top bytes are ignored), this will however change the color component for out of bound color + effect.withColor(Color.fromRGB(color & 0xFFFFFF)); // Paper - try to keep color component consistent with vanilla (top byte is ignored), this will however change the color component for out of bound color
} }
for (int color : explosion.fadeColors()) { for (int color : explosion.fadeColors()) {
@ -1105,7 +1105,7 @@ index 12a193db7475870e5107c86c7611bb4b92feacb8..c235b80b94fdb6c77766016114713cd5
return (result != null) ? result : Optional.empty(); return (result != null) ? result : Optional.empty();
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java
index 157a7b7351f48e68d2923c72ed3bbe3dcae21383..ce8cd736ababe3e6153efe27f943c027fb920fb2 100644 index 157a7b7351f48e68d2923c72ed3bbe3dcae21383..70c0d4cc85c045d040a35cd406f3f7ce9b6a58fa 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java
@@ -28,16 +28,30 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta { @@ -28,16 +28,30 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta {
@ -1113,7 +1113,7 @@ index 157a7b7351f48e68d2923c72ed3bbe3dcae21383..ce8cd736ababe3e6153efe27f943c027
static final ItemMetaKeyType<DyedItemColor> COLOR = new ItemMetaKeyType<>(DataComponents.DYED_COLOR, "color"); static final ItemMetaKeyType<DyedItemColor> COLOR = new ItemMetaKeyType<>(DataComponents.DYED_COLOR, "color");
- private Color color = DEFAULT_LEATHER_COLOR; - private Color color = DEFAULT_LEATHER_COLOR;
+ private Integer color; // Paper - keep color component consistent with vanilla (top bytes are ignored) + private Integer color; // Paper - keep color component consistent with vanilla (top byte is ignored)
CraftMetaLeatherArmor(CraftMetaItem meta) { CraftMetaLeatherArmor(CraftMetaItem meta) {
super(meta); super(meta);
@ -1211,7 +1211,7 @@ index 157a7b7351f48e68d2923c72ed3bbe3dcae21383..ce8cd736ababe3e6153efe27f943c027
if (CraftMetaLeatherArmor.hasColor(meta)) { if (CraftMetaLeatherArmor.hasColor(meta)) {
tag.put(CraftMetaLeatherArmor.COLOR, new DyedItemColor(meta.getColor().asRGB(), !meta.hasItemFlag(ItemFlag.HIDE_DYE))); tag.put(CraftMetaLeatherArmor.COLOR, new DyedItemColor(meta.getColor().asRGB(), !meta.hasItemFlag(ItemFlag.HIDE_DYE)));
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
index d829f4da371b44e7480896118547734be400a314..b6c18563de5b0d7a5a4253bdd01e98d843ce3797 100644 index d829f4da371b44e7480896118547734be400a314..0ff40e10ce8bab8010222ef7697d585430aeda03 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
@@ -30,7 +30,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { @@ -30,7 +30,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
@ -1219,7 +1219,7 @@ index d829f4da371b44e7480896118547734be400a314..b6c18563de5b0d7a5a4253bdd01e98d8
private Integer mapId; private Integer mapId;
private byte scaling = CraftMetaMap.SCALING_EMPTY; private byte scaling = CraftMetaMap.SCALING_EMPTY;
- private Color color; - private Color color;
+ private Integer color; // Paper - keep color component consistent with vanilla (top bytes are ignored) + private Integer color; // Paper - keep color component consistent with vanilla (top byte is ignored)
CraftMetaMap(CraftMetaItem meta) { CraftMetaMap(CraftMetaItem meta) {
super(meta); super(meta);
@ -1277,7 +1277,7 @@ index 7197c4f5698fd041c4db6d0f6a80c55f77661789..062ef890b42075adb5663453806dda3a
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
index db7f71af22d904de08d4badaa7f66d1286d5bf16..b34d581682b81760e35b1748e21a01f5473edf33 100644 index db7f71af22d904de08d4badaa7f66d1286d5bf16..e32143e140db50a11cf602cf622d68b787c0d647 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
@@ -47,7 +47,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { @@ -47,7 +47,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
@ -1285,7 +1285,7 @@ index db7f71af22d904de08d4badaa7f66d1286d5bf16..b34d581682b81760e35b1748e21a01f5
private PotionType type; private PotionType type;
private List<PotionEffect> customEffects; private List<PotionEffect> customEffects;
- private Color color; - private Color color;
+ private Integer color; // Paper - keep color component consistent with vanilla (top bytes are ignored) + private Integer color; // Paper - keep color component consistent with vanilla (top byte is ignored)
CraftMetaPotion(CraftMetaItem meta) { CraftMetaPotion(CraftMetaItem meta) {
super(meta); super(meta);