Clear firework item properly (#10793)

This commit is contained in:
Lulu13022002 2024-05-26 19:57:38 +02:00
parent 37155664bb
commit fff2347845
2 changed files with 8 additions and 8 deletions

View file

@ -527,7 +527,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
); );
- 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);
@ -688,7 +688,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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()) {
@ -1113,7 +1113,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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);
@ -1219,7 +1219,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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);
@ -1285,7 +1285,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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);

View file

@ -168,7 +168,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- this.getHandle().projectileSource = shooter; - this.getHandle().projectileSource = shooter;
- } - }
+ // Paper - moved to AbstractProjectil + // Paper - moved to AbstractProjectile
@Override @Override
public boolean isInBlock() { public boolean isInBlock() {
@ -270,7 +270,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- 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 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @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);