3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-Server-Patches/0136-Firework-API-s.patch
Aikar e4d10a6d67
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
122289ff Add FaceAttachable interface to handle Grindstone facing in common with Switches
a6db750e SPIGOT-5647: ZombieVillager entity should have getVillagerType()

CraftBukkit Changes:
bbe3d58e SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException
3075579f Add FaceAttachable interface to handle Grindstone facing in common with Switches
95bd4238 SPIGOT-5647: ZombieVillager entity should have getVillagerType()
4d975ac3 SPIGOT-5617: setBlockData does not work when NotPlayEvent is called by redstone current
2020-04-02 17:09:17 -04:00

150 Zeilen
6.8 KiB
Diff

From 2343191bdb15c6a3287804f78858c35fd631aef5 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 4f51b9b654..278ef79d89 100644
--- a/src/main/java/net/minecraft/server/EntityFireworks.java
+++ b/src/main/java/net/minecraft/server/EntityFireworks.java
@@ -3,6 +3,8 @@ package net.minecraft.server;
import java.util.Iterator;
import java.util.List;
import java.util.OptionalInt;
+import java.util.UUID;
+
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class EntityFireworks extends Entity implements IProjectile {
@@ -12,7 +14,8 @@ public class EntityFireworks extends Entity implements IProjectile {
public static final DataWatcherObject<Boolean> SHOT_AT_ANGLE = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.i);
private int ticksFlown;
public int expectedLifespan;
- private EntityLiving ridingEntity;
+ private EntityLiving ridingEntity; public final EntityLiving getBoostedEntity() { return this.ridingEntity; } // Paper - OBFHELPER
+ public UUID spawningEntity; // Paper
public EntityFireworks(EntityTypes<? extends EntityFireworks> entitytypes, World world) {
super(entitytypes, world);
@@ -268,6 +271,11 @@ public class EntityFireworks extends Entity implements 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
@@ -283,7 +291,11 @@ public class EntityFireworks extends Entity implements 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 313076d6d8..7be41c8698 100644
--- 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.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 058c016b7b..92dac35ec4 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, 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 75604dbc69..98deaba12c 100644
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
@@ -136,7 +136,7 @@ public class NBTTagCompound implements NBTBase {
return new UUID(this.getLong(s + "Most"), this.getLong(s + "Least"));
}
- public boolean b(String s) {
+ public final boolean hasUUID(String s) { return this.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 475b7b004b..de74e7214a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
import java.util.Random;
import net.minecraft.server.EntityFireworks;
+import net.minecraft.server.EntityLiving;
import net.minecraft.server.ItemStack;
import net.minecraft.server.Items;
import org.bukkit.Material;
@@ -9,8 +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.UUID;
+
public class CraftFirework extends CraftEntity implements Firework {
private final Random random = new Random();
@@ -78,4 +82,17 @@ public class CraftFirework extends CraftEntity implements Firework {
public void setShotAtAngle(boolean shotAtAngle) {
getHandle().getDataWatcher().set(EntityFireworks.SHOT_AT_ANGLE, shotAtAngle);
}
+
+ // 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.25.1