13
0
geforkt von Mirrors/Paper

Ensure the item sent isn't air (#7584)

Dieser Commit ist enthalten in:
Owen1212055 2022-03-12 15:34:03 -05:00
Ursprung 35cc32c4a1
Commit ac137edbc7

Datei anzeigen

@ -60,11 +60,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void setFireworkMeta(FireworkMeta meta) { public void setFireworkMeta(FireworkMeta meta) {
- this.item.setItemMeta(meta); - this.item.setItemMeta(meta);
+ applyFireworkEffect(meta); // Paper - Expose firework item directly + applyFireworkEffect(meta); // Paper - Expose firework item directly
// Copied from EntityFireworks constructor, update firework lifetime/power // Copied from EntityFireworks constructor, update firework lifetime/power
this.getHandle().lifetime = 10 * (1 + meta.getPower()) + this.random.nextInt(6) + this.random.nextInt(7); this.getHandle().lifetime = 10 * (1 + meta.getPower()) + this.random.nextInt(6) + this.random.nextInt(7);
@@ -0,0 +0,0 @@ public class CraftFirework extends CraftProjectile implements Firework { @@ -0,0 +0,0 @@ public class CraftFirework extends CraftProjectile implements Firework {
return boostedEntity != null ? (org.bukkit.entity.LivingEntity) boostedEntity.getBukkitEntity() : null; return boostedEntity != null ? (org.bukkit.entity.LivingEntity) boostedEntity.getBukkitEntity() : null;
} }
@ -78,7 +77,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();
+ var nmsItem = itemStack == null ? ItemStack.EMPTY : CraftItemStack.asNMSCopy(itemStack); + ItemStack nmsItem = itemStack == null ? ItemStack.EMPTY : 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);
@ -105,7 +104,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ void applyFireworkEffect(FireworkMeta meta) { + void applyFireworkEffect(FireworkMeta meta) {
+ CraftItemStack.applyMetaToItem(this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM), meta); + ItemStack item = this.getHandle().getItem();
+ CraftItemStack.applyMetaToItem(item, meta);
+
+ this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, item);
+ } + }
+ // Paper end - Expose firework item directly + manually setting flight + // Paper end - Expose firework item directly + manually setting flight
} }
@ -133,8 +135,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Override + @Override
+ public void setPotionMeta(org.bukkit.inventory.meta.PotionMeta meta) { + public void setPotionMeta(org.bukkit.inventory.meta.PotionMeta meta) {
+ CraftItemStack.applyMetaToItem(this.getHandle().getItemRaw(), meta); + net.minecraft.world.item.ItemStack item = this.getHandle().getItem();
+ this.getHandle().setItem(this.getHandle().getItemRaw()); // Reset item + CraftItemStack.applyMetaToItem(item, meta);
+ this.getHandle().setItem(item); // Reset item
+ } + }
+ // Paper end + // Paper end
@Override @Override