Paper/Spigot-Server-Patches/0132-Firework-API-s.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

117 lines
6.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 28 Dec 2016 07:18:33 +0100
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 b350825141e7a0d71a7362f1faf01c41d769a14f..36729e478329cdcd4af6132f3024963314bc4c61 100644
--- a/src/main/java/net/minecraft/server/EntityFireworks.java
+++ b/src/main/java/net/minecraft/server/EntityFireworks.java
@@ -13,7 +13,8 @@ public class EntityFireworks extends IProjectile {
public static final DataWatcherObject<Boolean> SHOT_AT_ANGLE = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.i);
private int ticksFlown;
public int expectedLifespan;
- private EntityLiving ridingEntity;
+ public EntityLiving ridingEntity; // Paper - public
+ public java.util.UUID spawningEntity; // Paper
public EntityFireworks(EntityTypes<? extends EntityFireworks> entitytypes, World world) {
super(entitytypes, world);
@@ -258,6 +259,11 @@ public class EntityFireworks extends IProjectile {
}
nbttagcompound.setBoolean("ShotAtAngle", (Boolean) this.datawatcher.get(EntityFireworks.SHOT_AT_ANGLE));
+ // Paper start
+ if (this.spawningEntity != null) {
+ nbttagcompound.setUUID("SpawningEntity", this.spawningEntity);
+ }
+ // Paper end
}
@Override
@@ -274,7 +280,11 @@ public class EntityFireworks extends IProjectile {
if (nbttagcompound.hasKey("ShotAtAngle")) {
this.datawatcher.set(EntityFireworks.SHOT_AT_ANGLE, nbttagcompound.getBoolean("ShotAtAngle"));
}
-
+ // Paper start
+ if (nbttagcompound.hasUUID("SpawningEntity")) {
+ this.spawningEntity = nbttagcompound.getUUID("SpawningEntity");
+ }
+ // Paper end
}
@Override
diff --git a/src/main/java/net/minecraft/server/ItemCrossbow.java b/src/main/java/net/minecraft/server/ItemCrossbow.java
index a2549cf1253f472d58ce68e4414448561a7a5ba4..1592e94c78611a4b968bfb24daf68570e778fadd 100644
--- a/src/main/java/net/minecraft/server/ItemCrossbow.java
+++ b/src/main/java/net/minecraft/server/ItemCrossbow.java
@@ -183,6 +183,7 @@ public class ItemCrossbow extends ItemProjectileWeapon implements ItemVanishable
if (flag1) {
object = new EntityFireworks(world, itemstack1, entityliving, entityliving.locX(), entityliving.getHeadY() - 0.15000000596046448D, entityliving.locZ(), true);
+ ((EntityFireworks) object).spawningEntity = entityliving.getUniqueID(); // Paper
} else {
object = a(world, entityliving, itemstack, itemstack1);
if (flag || f3 != 0.0F) {
diff --git a/src/main/java/net/minecraft/server/ItemFireworks.java b/src/main/java/net/minecraft/server/ItemFireworks.java
index 12ae2d9b747b69533fab2487ad55626c50c1d620..6cc243025f5bdac9be39f8a88a018893a9941dba 100644
--- a/src/main/java/net/minecraft/server/ItemFireworks.java
+++ b/src/main/java/net/minecraft/server/ItemFireworks.java
@@ -18,6 +18,7 @@ public class ItemFireworks extends Item {
Vec3D vec3d = itemactioncontext.getPos();
EnumDirection enumdirection = itemactioncontext.getClickedFace();
EntityFireworks entityfireworks = new EntityFireworks(world, itemactioncontext.getEntity(), vec3d.x + (double) enumdirection.getAdjacentX() * 0.15D, vec3d.y + (double) enumdirection.getAdjacentY() * 0.15D, vec3d.z + (double) enumdirection.getAdjacentZ() * 0.15D, itemstack);
+ entityfireworks.spawningEntity = itemactioncontext.getEntity().getUniqueID(); // Paper
world.addEntity(entityfireworks);
itemstack.subtract(1);
@@ -32,7 +33,11 @@ public class ItemFireworks extends Item {
ItemStack itemstack = entityhuman.b(enumhand);
if (!world.isClientSide) {
- 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
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 c16ff6723d3fd191b990002d40dc021d7870555d..9c445902e6adc05773497bc4444203ca364e4f5c 100644
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
@@ -145,6 +145,7 @@ public class NBTTagCompound implements NBTBase {
return GameProfileSerializer.a(this.get(s));
}
+ public final boolean hasUUID(String s) { return this.b(s); } // Paper - OBFHELPER
public boolean b(String s) {
NBTBase nbtbase = this.get(s);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
index d984a7a78e9f8536abf7c30df9aa59dbfc7984ce..f3066e6c781bcee72c235abcef5060fb080892d5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
@@ -78,4 +78,17 @@ public class CraftFirework extends CraftProjectile implements Firework {
public void setShotAtAngle(boolean shotAtAngle) {
getHandle().getDataWatcher().set(EntityFireworks.SHOT_AT_ANGLE, shotAtAngle);
}
+
+ // Paper start
+ @Override
+ public java.util.UUID getSpawningEntity() {
+ return getHandle().spawningEntity;
+ }
+
+ @Override
+ public org.bukkit.entity.LivingEntity getBoostedEntity() {
+ net.minecraft.server.EntityLiving boostedEntity = getHandle().ridingEntity;
+ return boostedEntity != null ? (org.bukkit.entity.LivingEntity) boostedEntity.getBukkitEntity() : null;
+ }
+ // Paper end
}