mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
125 lines
6.3 KiB
Diff
125 lines
6.3 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/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||
|
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||
|
@@ -0,0 +0,0 @@ public class CompoundTag implements Tag {
|
||
|
return NbtUtils.loadUUID(this.get(key));
|
||
|
}
|
||
|
|
||
|
+ public final boolean hasUUID(String s) { return this.hasUUID(s); } // Paper - OBFHELPER
|
||
|
public boolean hasUUID(String key) {
|
||
|
Tag nbtbase = this.get(key);
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
||
|
@@ -0,0 +0,0 @@ public class FireworkRocketEntity extends Projectile {
|
||
|
public static final EntityDataAccessor<Boolean> DATA_SHOT_AT_ANGLE = SynchedEntityData.defineId(FireworkRocketEntity.class, EntityDataSerializers.BOOLEAN);
|
||
|
private int life;
|
||
|
public int lifetime;
|
||
|
- private LivingEntity attachedToEntity;
|
||
|
+ public LivingEntity attachedToEntity; // Paper - public
|
||
|
+ public java.util.UUID spawningEntity; // Paper
|
||
|
|
||
|
public FireworkRocketEntity(EntityType<? extends FireworkRocketEntity> type, Level world) {
|
||
|
super(type, world);
|
||
|
@@ -0,0 +0,0 @@ public class FireworkRocketEntity extends Projectile {
|
||
|
}
|
||
|
|
||
|
tag.putBoolean("ShotAtAngle", (Boolean) this.entityData.get(FireworkRocketEntity.DATA_SHOT_AT_ANGLE));
|
||
|
+ // Paper start
|
||
|
+ if (this.spawningEntity != null) {
|
||
|
+ tag.setUUID("SpawningEntity", this.spawningEntity);
|
||
|
+ }
|
||
|
+ // Paper end
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@@ -0,0 +0,0 @@ public class FireworkRocketEntity extends Projectile {
|
||
|
if (tag.contains("ShotAtAngle")) {
|
||
|
this.entityData.set(FireworkRocketEntity.DATA_SHOT_AT_ANGLE, tag.getBoolean("ShotAtAngle"));
|
||
|
}
|
||
|
-
|
||
|
+ // Paper start
|
||
|
+ if (tag.hasUUID("SpawningEntity")) {
|
||
|
+ this.spawningEntity = tag.getUUID("SpawningEntity");
|
||
|
+ }
|
||
|
+ // Paper end
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||
|
@@ -0,0 +0,0 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
|
||
|
|
||
|
if (flag1) {
|
||
|
object = new FireworkRocketEntity(world, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15000000596046448D, shooter.getZ(), true);
|
||
|
+ ((FireworkRocketEntity) object).spawningEntity = shooter.getUUID(); // Paper
|
||
|
} else {
|
||
|
object = getArrow(world, shooter, crossbow, projectile);
|
||
|
if (creative || simulated != 0.0F) {
|
||
|
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||
|
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item {
|
||
|
Vec3 vec3d = context.getClickLocation();
|
||
|
Direction enumdirection = context.getClickedFace();
|
||
|
FireworkRocketEntity entityfireworks = new FireworkRocketEntity(world, context.getPlayer(), vec3d.x + (double) enumdirection.getStepX() * 0.15D, vec3d.y + (double) enumdirection.getStepY() * 0.15D, vec3d.z + (double) enumdirection.getStepZ() * 0.15D, itemstack);
|
||
|
+ entityfireworks.spawningEntity = context.getPlayer().getUUID(); // Paper
|
||
|
|
||
|
world.addFreshEntity(entityfireworks);
|
||
|
itemstack.shrink(1);
|
||
|
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item {
|
||
|
ItemStack itemstack = user.getItemInHand(hand);
|
||
|
|
||
|
if (!world.isClientSide) {
|
||
|
- world.addFreshEntity(new FireworkRocketEntity(world, itemstack, user));
|
||
|
+ // Paper start
|
||
|
+ final FireworkRocketEntity entityfireworks = new FireworkRocketEntity(world, itemstack, user);
|
||
|
+ entityfireworks.spawningEntity = user.getUUID();
|
||
|
+ world.addFreshEntity(entityfireworks);
|
||
|
+ // Paper end
|
||
|
if (!user.abilities.instabuild) {
|
||
|
itemstack.shrink(1);
|
||
|
}
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
||
|
@@ -0,0 +0,0 @@
|
||
|
package org.bukkit.craftbukkit.entity;
|
||
|
|
||
|
import java.util.Random;
|
||
|
+import net.minecraft.world.entity.LivingEntity;
|
||
|
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
||
|
import net.minecraft.world.item.ItemStack;
|
||
|
import net.minecraft.world.item.Items;
|
||
|
@@ -0,0 +0,0 @@ public class CraftFirework extends CraftProjectile implements Firework {
|
||
|
public void setShotAtAngle(boolean shotAtAngle) {
|
||
|
getHandle().getEntityData().set(FireworkRocketEntity.DATA_SHOT_AT_ANGLE, shotAtAngle);
|
||
|
}
|
||
|
+
|
||
|
+ // Paper start
|
||
|
+ @Override
|
||
|
+ public java.util.UUID getSpawningEntity() {
|
||
|
+ return getHandle().spawningEntity;
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public org.bukkit.entity.LivingEntity getBoostedEntity() {
|
||
|
+ LivingEntity boostedEntity = getHandle().attachedToEntity;
|
||
|
+ return boostedEntity != null ? (org.bukkit.entity.LivingEntity) boostedEntity.getBukkitEntity() : null;
|
||
|
+ }
|
||
|
+ // Paper end
|
||
|
}
|