2019-08-05 18:35:40 +02:00
|
|
|
From 5cc70c7a81386cc66cead409e9f0e90d4ccd07af Mon Sep 17 00:00:00 2001
|
2016-12-28 08:25:35 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
2019-07-24 05:12:40 +02:00
|
|
|
Date: Wed, 28 Dec 2016 07:18:33 +0100
|
2016-12-28 08:25:35 +01:00
|
|
|
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-08-05 18:35:40 +02:00
|
|
|
index fd3897c056..3cf3b1c174 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
|
2019-04-27 08:26:04 +02:00
|
|
|
@@ -3,6 +3,8 @@ package net.minecraft.server;
|
2016-12-28 08:25:35 +01:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
2019-04-27 08:26:04 +02:00
|
|
|
import java.util.OptionalInt;
|
2016-12-28 08:25:35 +01:00
|
|
|
+import java.util.UUID;
|
|
|
|
+
|
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
public class EntityFireworks extends Entity implements IProjectile {
|
|
|
|
@@ -12,7 +14,8 @@ public class EntityFireworks extends Entity implements IProjectile {
|
2019-08-05 18:35:40 +02:00
|
|
|
public static final DataWatcherObject<Boolean> d = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.i); // PAIL
|
2016-12-28 08:25:35 +01:00
|
|
|
private int ticksFlown;
|
|
|
|
public int expectedLifespan;
|
2019-04-27 08:26:04 +02:00
|
|
|
- private EntityLiving ridingEntity;
|
|
|
|
+ private EntityLiving ridingEntity; public final EntityLiving getBoostedEntity() { return this.ridingEntity; } // Paper - OBFHELPER
|
2016-12-28 08:25:35 +01:00
|
|
|
+ public UUID spawningEntity; // Paper
|
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
public EntityFireworks(EntityTypes<? extends EntityFireworks> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
2019-08-05 18:35:40 +02:00
|
|
|
@@ -263,6 +266,11 @@ public class EntityFireworks extends Entity implements IProjectile {
|
2016-12-28 08:25:35 +01:00
|
|
|
}
|
2018-09-01 00:56:57 +02:00
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
nbttagcompound.setBoolean("ShotAtAngle", (Boolean) this.datawatcher.get(EntityFireworks.d));
|
2016-12-28 08:25:35 +01:00
|
|
|
+ // Paper start
|
2019-04-27 08:26:04 +02:00
|
|
|
+ if (this.spawningEntity != null) {
|
|
|
|
+ nbttagcompound.setUUID("SpawningEntity", this.spawningEntity);
|
2016-12-28 08:25:35 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
@Override
|
2019-08-05 18:35:40 +02:00
|
|
|
@@ -278,7 +286,11 @@ public class EntityFireworks extends Entity implements IProjectile {
|
2019-04-27 08:26:04 +02:00
|
|
|
if (nbttagcompound.hasKey("ShotAtAngle")) {
|
|
|
|
this.datawatcher.set(EntityFireworks.d, nbttagcompound.getBoolean("ShotAtAngle"));
|
2016-12-28 08:25:35 +01:00
|
|
|
}
|
|
|
|
-
|
|
|
|
+ // Paper start
|
|
|
|
+ if (nbttagcompound.hasUUID("SpawningEntity")) {
|
2019-04-27 08:26:04 +02:00
|
|
|
+ this.spawningEntity = nbttagcompound.getUUID("SpawningEntity");
|
2016-12-28 08:25:35 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
@Override
|
2019-07-24 05:12:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemCrossbow.java b/src/main/java/net/minecraft/server/ItemCrossbow.java
|
2019-08-05 18:35:40 +02:00
|
|
|
index 28d7fdeef8..874d9f500e 100644
|
2019-07-24 05:12:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemCrossbow.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemCrossbow.java
|
|
|
|
@@ -199,6 +199,7 @@ public class ItemCrossbow extends ItemProjectileWeapon {
|
|
|
|
|
|
|
|
if (flag1) {
|
|
|
|
object = new EntityFireworks(world, itemstack1, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.15000000596046448D, entityliving.locZ, true);
|
|
|
|
+ ((EntityFireworks) object).spawningEntity = entityliving.getUniqueID(); // Paper
|
|
|
|
} else {
|
|
|
|
object = a(world, entityliving, itemstack, itemstack1);
|
|
|
|
if (flag || f3 != 0.0F) {
|
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-08-05 18:35:40 +02:00
|
|
|
index 37caa79cba..aea46ffae5 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-04-27 08:26:04 +02:00
|
|
|
@@ -17,6 +17,7 @@ public class ItemFireworks extends Item {
|
2018-07-17 22:32:05 +02:00
|
|
|
ItemStack itemstack = itemactioncontext.getItemStack();
|
2019-04-27 08:26:04 +02:00
|
|
|
Vec3D vec3d = itemactioncontext.j();
|
|
|
|
EntityFireworks entityfireworks = new EntityFireworks(world, vec3d.x, vec3d.y, vec3d.z, itemstack);
|
|
|
|
+ entityfireworks.spawningEntity = itemactioncontext.getEntity().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-04-27 08:26:04 +02:00
|
|
|
@@ -31,7 +32,11 @@ public class ItemFireworks extends Item {
|
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2016-12-28 08:25:35 +01:00
|
|
|
if (!world.isClientSide) {
|
2019-04-27 08:26:04 +02:00
|
|
|
- world.addEntity(new EntityFireworks(world, itemstack, entityhuman));
|
|
|
|
+ // Paper start
|
|
|
|
+ final EntityFireworks entityfireworks = new EntityFireworks(world, itemstack, entityhuman);
|
|
|
|
+ entityfireworks.spawningEntity = entityhuman.getUniqueID();
|
|
|
|
+ world.addEntity(entityfireworks);
|
|
|
|
+ // Paper end
|
2016-12-28 08:25:35 +01:00
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
2019-04-27 08:26:04 +02:00
|
|
|
itemstack.subtract(1);
|
|
|
|
}
|
2016-12-28 08:25:35 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
2019-08-05 18:35:40 +02:00
|
|
|
index 3f6d2676e7..b1fd18151b 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-04-27 08:26:04 +02:00
|
|
|
@@ -112,7 +112,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) {
|
2019-04-27 08:26:04 +02:00
|
|
|
+ public final boolean hasUUID(String s) { return this.b(s); } public boolean b(String s) { // Paper - OBFHELPER
|
2016-12-28 08:25:35 +01:00
|
|
|
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
|
2019-08-05 18:35:40 +02:00
|
|
|
index d3cbad9a5c..219a1e4c0d 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
|
2019-04-27 08:26:04 +02:00
|
|
|
@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
|
2016-12-28 08:25:35 +01:00
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
import java.util.Random;
|
2016-12-28 08:25:35 +01:00
|
|
|
import net.minecraft.server.EntityFireworks;
|
|
|
|
+import net.minecraft.server.EntityLiving;
|
|
|
|
import net.minecraft.server.ItemStack;
|
|
|
|
import net.minecraft.server.Items;
|
2019-04-27 08:26:04 +02:00
|
|
|
import org.bukkit.Material;
|
|
|
|
@@ -9,8 +10,11 @@ import org.bukkit.craftbukkit.CraftServer;
|
2016-12-28 08:25:35 +01:00
|
|
|
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.UUID;
|
2019-04-27 08:26:04 +02:00
|
|
|
+
|
2016-12-28 08:25:35 +01:00
|
|
|
public class CraftFirework extends CraftEntity implements Firework {
|
|
|
|
|
2019-04-27 08:26:04 +02:00
|
|
|
private final Random random = new Random();
|
2019-08-05 18:35:40 +02:00
|
|
|
@@ -78,4 +82,17 @@ public class CraftFirework extends CraftEntity implements Firework {
|
|
|
|
public void setShotAtAngle(boolean shotAtAngle) {
|
|
|
|
getHandle().getDataWatcher().set(EntityFireworks.d, shotAtAngle);
|
2016-12-28 08:25:35 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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-08-05 18:35:40 +02:00
|
|
|
2.22.0
|
2016-12-28 08:25:35 +01:00
|
|
|
|