Firework API's

== AT ==
public net.minecraft.world.entity.projectile.FireworkRocketEntity attachedToEntity
This commit is contained in:
Aikar
2016-12-28 07:18:33 +01:00
parent 26ff64cadc
commit 746f540e81
4 changed files with 81 additions and 6 deletions

View File

@@ -10,7 +10,15 @@
public class FireworkRocketEntity extends Projectile implements ItemSupplier {
@@ -84,7 +87,29 @@
@@ -42,6 +45,7 @@
public int lifetime;
@Nullable
public LivingEntity attachedToEntity;
+ @Nullable public java.util.UUID spawningEntity; // Paper
public FireworkRocketEntity(EntityType<? extends FireworkRocketEntity> type, Level world) {
super(type, world);
@@ -84,7 +88,29 @@
this.setOwner(entity);
}
@@ -40,7 +48,7 @@
protected void defineSynchedData(SynchedEntityData.Builder builder) {
builder.define(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, FireworkRocketEntity.getDefaultItem());
builder.define(FireworkRocketEntity.DATA_ATTACHED_TO_TARGET, OptionalInt.empty());
@@ -152,7 +177,7 @@
@@ -152,7 +178,7 @@
}
if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != HitResult.Type.MISS) {
@@ -49,7 +57,7 @@
this.hasImpulse = true;
}
@@ -172,7 +197,11 @@
@@ -172,7 +198,11 @@
if (world instanceof ServerLevel) {
ServerLevel worldserver = (ServerLevel) world;
@@ -62,7 +70,7 @@
}
}
@@ -182,7 +211,7 @@
@@ -182,7 +212,7 @@
world.broadcastEntityEvent(this, (byte) 17);
this.gameEvent(GameEvent.EXPLODE, this.getOwner());
this.dealExplosionDamage(world);
@@ -71,7 +79,7 @@
}
@Override
@@ -191,7 +220,11 @@
@@ -191,7 +221,11 @@
Level world = this.level();
if (world instanceof ServerLevel worldserver) {
@@ -84,7 +92,7 @@
}
}
@@ -205,7 +238,11 @@
@@ -205,7 +239,11 @@
if (world instanceof ServerLevel worldserver) {
if (this.hasExplosion()) {
@@ -97,3 +105,28 @@
}
}
@@ -287,6 +325,11 @@
nbt.putInt("LifeTime", this.lifetime);
nbt.put("FireworksItem", this.getItem().save(this.registryAccess()));
nbt.putBoolean("ShotAtAngle", (Boolean) this.entityData.get(FireworkRocketEntity.DATA_SHOT_AT_ANGLE));
+ // Paper start
+ if (this.spawningEntity != null) {
+ nbt.putUUID("SpawningEntity", this.spawningEntity);
+ }
+ // Paper end
}
@Override
@@ -303,7 +346,11 @@
if (nbt.contains("ShotAtAngle")) {
this.entityData.set(FireworkRocketEntity.DATA_SHOT_AT_ANGLE, nbt.getBoolean("ShotAtAngle"));
}
-
+ // Paper start
+ if (nbt.hasUUID("SpawningEntity")) {
+ this.spawningEntity = nbt.getUUID("SpawningEntity");
+ }
+ // Paper end
}
private List<FireworkExplosion> getExplosions() {