From 49aca0c04d4cf81499d57dcd60d20ebe14908497 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 28 Dec 2016 02:25:35 -0500 Subject: [PATCH] New Firework API's Get the launcher of a Firework and who it is boosting --- Spigot-API-Patches/0047-Fireworks-API-s.patch | 38 +++++ .../0196-Firework-API-s.patch | 133 ++++++++++++++++++ scripts/importmcdev.sh | 1 + 3 files changed, 172 insertions(+) create mode 100644 Spigot-API-Patches/0047-Fireworks-API-s.patch create mode 100644 Spigot-Server-Patches/0196-Firework-API-s.patch diff --git a/Spigot-API-Patches/0047-Fireworks-API-s.patch b/Spigot-API-Patches/0047-Fireworks-API-s.patch new file mode 100644 index 0000000000..8af372d27a --- /dev/null +++ b/Spigot-API-Patches/0047-Fireworks-API-s.patch @@ -0,0 +1,38 @@ +From ba197c354dadaeddf148c2dc6533e84b47bc30c4 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 28 Dec 2016 01:18:55 -0500 +Subject: [PATCH] Fireworks API's + +Get the Entity being boosted +Get the firework launcher + +diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java +index b8a8c075..8c087bb7 100644 +--- a/src/main/java/org/bukkit/entity/Firework.java ++++ b/src/main/java/org/bukkit/entity/Firework.java +@@ -2,6 +2,8 @@ package org.bukkit.entity; + + import org.bukkit.inventory.meta.FireworkMeta; + ++import java.util.UUID; ++ + public interface Firework extends Entity { + + /** +@@ -23,4 +25,13 @@ public interface Firework extends Entity { + * remaining fuse. + */ + void detonate(); ++ ++ // Paper start ++ public UUID getSpawningEntity(); ++ /** ++ * If this firework is boosting an entity, return it ++ * @return The entity being boosted ++ */ ++ public LivingEntity getBoostedEntity(); ++ // Paper end + } +-- +2.11.0 + diff --git a/Spigot-Server-Patches/0196-Firework-API-s.patch b/Spigot-Server-Patches/0196-Firework-API-s.patch new file mode 100644 index 0000000000..a23ad8bb02 --- /dev/null +++ b/Spigot-Server-Patches/0196-Firework-API-s.patch @@ -0,0 +1,133 @@ +From 503217c476bbdf4c6cc5b9821fea7a4cce7fc674 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 28 Dec 2016 01:18:33 -0500 +Subject: [PATCH] Firework API's + + +diff --git a/src/main/java/net/minecraft/server/EntityFireworks.java b/src/main/java/net/minecraft/server/EntityFireworks.java +index 572f4dead..f9cf382b2 100644 +--- a/src/main/java/net/minecraft/server/EntityFireworks.java ++++ b/src/main/java/net/minecraft/server/EntityFireworks.java +@@ -2,6 +2,8 @@ package net.minecraft.server; + + import java.util.Iterator; + import java.util.List; ++import java.util.UUID; ++ + import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + + public class EntityFireworks extends Entity { +@@ -10,7 +12,8 @@ public class EntityFireworks extends Entity { + private static final DataWatcherObject b = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.b); + private int ticksFlown; + public int expectedLifespan; +- private EntityLiving e; ++ public UUID spawningEntity; // Paper ++ private EntityLiving e;public EntityLiving getBoostedEntity() { return e; } // Paper - OBFHELPER + + public EntityFireworks(World world) { + super(world); +@@ -203,6 +206,11 @@ public class EntityFireworks extends Entity { + if (!itemstack.isEmpty()) { + nbttagcompound.set("FireworksItem", itemstack.save(new NBTTagCompound())); + } ++ // Paper start ++ if (spawningEntity != null) { ++ nbttagcompound.setUUID("SpawningEntity", spawningEntity); ++ } ++ // Paper end + + } + +@@ -218,7 +226,11 @@ public class EntityFireworks extends Entity { + this.datawatcher.set(EntityFireworks.FIREWORK_ITEM, itemstack); + } + } +- ++ // Paper start ++ if (nbttagcompound.hasUUID("SpawningEntity")) { ++ spawningEntity = nbttagcompound.getUUID("SpawningEntity"); ++ } ++ // Paper end + } + + public boolean aV() { +diff --git a/src/main/java/net/minecraft/server/ItemFireworks.java b/src/main/java/net/minecraft/server/ItemFireworks.java +index 4fc36d243..5cd68bfaf 100644 +--- a/src/main/java/net/minecraft/server/ItemFireworks.java ++++ b/src/main/java/net/minecraft/server/ItemFireworks.java +@@ -9,6 +9,7 @@ public class ItemFireworks extends Item { + ItemStack itemstack = entityhuman.b(enumhand); + EntityFireworks entityfireworks = new EntityFireworks(world, (double) ((float) blockposition.getX() + f), (double) ((float) blockposition.getY() + f1), (double) ((float) blockposition.getZ() + f2), itemstack); + ++ entityfireworks.spawningEntity = entityhuman.getUniqueID(); // Paper + world.addEntity(entityfireworks); + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); +@@ -25,6 +26,7 @@ public class ItemFireworks extends Item { + if (!world.isClientSide) { + EntityFireworks entityfireworks = new EntityFireworks(world, itemstack, entityhuman); + ++ entityfireworks.spawningEntity = entityhuman.getUniqueID(); // Paper + world.addEntity(entityfireworks); + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); +diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java +index 2a2f53c82..266741fcd 100644 +--- a/src/main/java/net/minecraft/server/NBTTagCompound.java ++++ b/src/main/java/net/minecraft/server/NBTTagCompound.java +@@ -103,7 +103,7 @@ public class NBTTagCompound extends NBTBase { + return new UUID(this.getLong(s + "Most"), this.getLong(s + "Least")); + } + +- public boolean b(String s) { ++ public boolean hasUUID(String s) { return b(s); } public boolean b(String s) { // Paper - OBFHELPER + return this.hasKeyOfType(s + "Most", 99) && this.hasKeyOfType(s + "Least", 99); + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +index 99746b3c2..d4fbe31d6 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +@@ -1,6 +1,7 @@ + package org.bukkit.craftbukkit.entity; + + import net.minecraft.server.EntityFireworks; ++import net.minecraft.server.EntityLiving; + import net.minecraft.server.ItemStack; + import net.minecraft.server.Items; + +@@ -9,9 +10,11 @@ import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.craftbukkit.inventory.CraftItemStack; + import org.bukkit.entity.EntityType; + import org.bukkit.entity.Firework; ++import org.bukkit.entity.LivingEntity; + import org.bukkit.inventory.meta.FireworkMeta; + + import java.util.Random; ++import java.util.UUID; + + public class CraftFirework extends CraftEntity implements Firework { + +@@ -70,4 +73,18 @@ public class CraftFirework extends CraftEntity implements Firework { + public void detonate() { + getHandle().expectedLifespan = 0; + } ++ ++ // Paper start ++ ++ @Override ++ public UUID getSpawningEntity() { ++ return getHandle().spawningEntity; ++ } ++ ++ @Override ++ public LivingEntity getBoostedEntity() { ++ EntityLiving boostedEntity = getHandle().getBoostedEntity(); ++ return boostedEntity != null ? (LivingEntity) boostedEntity.getBukkitEntity() : null; ++ } ++ // Paper end + } +-- +2.11.0 + diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 7afb66102e..998ce7d627 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -64,6 +64,7 @@ import EntityWaterAnimal import FileIOThread import IHopper import ItemBlock +import ItemFireworks import ItemMonsterEgg import NavigationAbstract import NBTTagCompound