2019-01-01 04:15:55 +01:00
|
|
|
From d3c8e46af030489991d076c9e2cc636b93013f8f Mon Sep 17 00:00:00 2001
|
2016-12-28 08:25:35 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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
|
2019-01-01 04:15:55 +01:00
|
|
|
index 9b6d217df..9764c76fb 100644
|
2016-12-28 08:25:35 +01:00
|
|
|
--- 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<Integer> 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) {
|
2018-07-17 22:32:05 +02:00
|
|
|
super(EntityTypes.FIREWORK_ROCKET, world);
|
2018-09-01 00:56:57 +02:00
|
|
|
@@ -197,6 +200,12 @@ public class EntityFireworks extends Entity {
|
2016-12-28 08:25:35 +01:00
|
|
|
nbttagcompound.set("FireworksItem", itemstack.save(new NBTTagCompound()));
|
|
|
|
}
|
2018-09-01 00:56:57 +02:00
|
|
|
|
2016-12-28 08:25:35 +01:00
|
|
|
+ // Paper start
|
|
|
|
+ if (spawningEntity != null) {
|
|
|
|
+ nbttagcompound.setUUID("SpawningEntity", spawningEntity);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2018-09-01 00:56:57 +02:00
|
|
|
+
|
2016-12-28 08:25:35 +01:00
|
|
|
}
|
|
|
|
|
2018-09-01 00:56:57 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
@@ -207,7 +216,11 @@ public class EntityFireworks extends Entity {
|
2018-07-17 22:32:05 +02:00
|
|
|
if (!itemstack.isEmpty()) {
|
|
|
|
this.datawatcher.set(EntityFireworks.FIREWORK_ITEM, itemstack);
|
2016-12-28 08:25:35 +01:00
|
|
|
}
|
|
|
|
-
|
|
|
|
+ // Paper start
|
|
|
|
+ if (nbttagcompound.hasUUID("SpawningEntity")) {
|
|
|
|
+ spawningEntity = nbttagcompound.getUUID("SpawningEntity");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2018-07-17 22:32:05 +02:00
|
|
|
public boolean bk() {
|
2016-12-28 08:25:35 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemFireworks.java b/src/main/java/net/minecraft/server/ItemFireworks.java
|
2019-01-01 04:15:55 +01:00
|
|
|
index 68bd2af26..dbb422e9d 100644
|
2016-12-28 08:25:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemFireworks.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemFireworks.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -16,6 +16,7 @@ public class ItemFireworks extends Item {
|
2018-09-01 00:56:57 +02:00
|
|
|
BlockPosition blockposition = itemactioncontext.getClickPosition();
|
2018-07-17 22:32:05 +02:00
|
|
|
ItemStack itemstack = itemactioncontext.getItemStack();
|
2019-01-01 04:15:55 +01:00
|
|
|
EntityFireworks entityfireworks = new EntityFireworks(world, (double) ((float) blockposition.getX() + itemactioncontext.m()), (double) ((float) blockposition.getY() + itemactioncontext.n()), (double) ((float) blockposition.getZ() + itemactioncontext.o()), itemstack);
|
2018-07-19 06:42:43 +02:00
|
|
|
+ entityfireworks.spawningEntity = itemactioncontext.b.getUniqueID(); // Paper
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2016-12-28 08:25:35 +01:00
|
|
|
world.addEntity(entityfireworks);
|
2018-07-17 22:32:05 +02:00
|
|
|
itemstack.subtract(1);
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -30,6 +31,7 @@ public class ItemFireworks extends Item {
|
|
|
|
|
2016-12-28 08:25:35 +01:00
|
|
|
if (!world.isClientSide) {
|
|
|
|
EntityFireworks entityfireworks = new EntityFireworks(world, itemstack, entityhuman);
|
|
|
|
+ entityfireworks.spawningEntity = entityhuman.getUniqueID(); // Paper
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2016-12-28 08:25:35 +01:00
|
|
|
world.addEntity(entityfireworks);
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
2019-01-01 04:15:55 +01:00
|
|
|
index 8c5d6c1d3..d4165f7e4 100644
|
2016-12-28 08:25:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -107,7 +107,7 @@ public class NBTTagCompound implements NBTBase {
|
2016-12-28 08:25:35 +01:00
|
|
|
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
|
2018-12-15 02:17:27 +01:00
|
|
|
index 7b3b20682..b39e33f4f 100644
|
2016-12-28 08:25:35 +01:00
|
|
|
--- 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
|
|
|
|
}
|
|
|
|
--
|
2019-01-01 04:15:55 +01:00
|
|
|
2.20.1
|
2016-12-28 08:25:35 +01:00
|
|
|
|