mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Add Entity Origin API
This replaces the TNT and Falling Block Source Location API with a more general purpose API that works with all entities.
This commit is contained in:
parent
eb5c119269
commit
bcc957e753
4 changed files with 181 additions and 272 deletions
|
@ -1,9 +1,29 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Byteflux <byte@byteflux.net>
|
From: Byteflux <byte@byteflux.net>
|
||||||
Date: Mon, 29 Feb 2016 17:50:31 -0600
|
Date: Mon, 29 Feb 2016 17:50:31 -0600
|
||||||
Subject: [PATCH] FallingBlock and TNTPrimed source location API
|
Subject: [PATCH] Entity Origin API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender {
|
||||||
|
|
||||||
|
Spigot spigot();
|
||||||
|
// Spigot End
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Gets the location where this entity originates from.
|
||||||
|
+ * <p>
|
||||||
|
+ * This value can be null if the entity hasn't yet been added to the world.
|
||||||
|
+ *
|
||||||
|
+ * @return Location where entity originates or null if not yet added
|
||||||
|
+ */
|
||||||
|
+ Location getOrigin();
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
|
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||||
|
@ -17,7 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * Gets the source block location of the FallingBlock
|
+ * Gets the source block location of the FallingBlock
|
||||||
+ *
|
+ *
|
||||||
+ * @return the source block location the FallingBlock was spawned from
|
+ * @return the source block location the FallingBlock was spawned from
|
||||||
|
+ * @deprecated replaced by {@link Entity#getOrigin()}
|
||||||
+ */
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
+ public org.bukkit.Location getSourceLoc();
|
+ public org.bukkit.Location getSourceLoc();
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||||
|
@ -33,7 +55,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * Gets the source block location of the TNTPrimed
|
+ * Gets the source block location of the TNTPrimed
|
||||||
+ *
|
+ *
|
||||||
+ * @return the source block location the TNTPrimed was spawned from
|
+ * @return the source block location the TNTPrimed was spawned from
|
||||||
|
+ * @deprecated replaced by {@link Entity#getOrigin()}
|
||||||
+ */
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
+ public org.bukkit.Location getSourceLoc();
|
+ public org.bukkit.Location getSourceLoc();
|
||||||
}
|
}
|
||||||
--
|
--
|
|
@ -144,27 +144,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/server/BlockTNT.java
|
--- a/src/main/java/net/minecraft/server/BlockTNT.java
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
|
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
|
||||||
@@ -0,0 +0,0 @@ public class BlockTNT extends Block {
|
@@ -0,0 +0,0 @@ public class BlockTNT extends Block {
|
||||||
|
|
||||||
public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
|
public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
org.bukkit.Location loc = explosion.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) explosion.source).sourceLoc : new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); // Paper
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource());
|
||||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource()); // Paper - Add loc
|
|
||||||
+ // Paper start - Fix cannons
|
+ // Paper start - Fix cannons
|
||||||
+ double y = blockposition.getY();
|
+ double y = blockposition.getY();
|
||||||
+ if (!world.paperConfig.fixCannons) y += 0.5;
|
+ if (!world.paperConfig.fixCannons) y += 0.5;
|
||||||
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), y, (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource()); // Paper - Add loc
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), y, (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource());
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
entitytntprimed.setFuseTicks((short) (world.random.nextInt(entitytntprimed.getFuseTicks() / 4) + entitytntprimed.getFuseTicks() / 8));
|
entitytntprimed.setFuseTicks((short) (world.random.nextInt(entitytntprimed.getFuseTicks() / 4) + entitytntprimed.getFuseTicks() / 8));
|
||||||
world.addEntity(entitytntprimed);
|
world.addEntity(entitytntprimed);
|
||||||
@@ -0,0 +0,0 @@ public class BlockTNT extends Block {
|
@@ -0,0 +0,0 @@ public class BlockTNT extends Block {
|
||||||
|
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) {
|
if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) {
|
||||||
org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); // Paper
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving);
|
||||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving); // Paper - Add loc
|
|
||||||
+ // Paper start - Fix cannons
|
+ // Paper start - Fix cannons
|
||||||
+ double y = blockposition.getY();
|
+ double y = blockposition.getY();
|
||||||
+ if (!world.paperConfig.fixCannons) y += 0.5;
|
+ if (!world.paperConfig.fixCannons) y += 0.5;
|
||||||
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), y, (double) ((float) blockposition.getZ() + 0.5F), entityliving); // Paper - Add loc
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), y, (double) ((float) blockposition.getZ() + 0.5F), entityliving);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
world.addEntity(entitytntprimed);
|
world.addEntity(entitytntprimed);
|
||||||
|
|
150
Spigot-Server-Patches/Entity-Origin-API.patch
Normal file
150
Spigot-Server-Patches/Entity-Origin-API.patch
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Byteflux <byte@byteflux.net>
|
||||||
|
Date: Tue, 1 Mar 2016 23:45:08 -0600
|
||||||
|
Subject: [PATCH] Entity Origin API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener {
|
||||||
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
|
||||||
|
public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
|
||||||
|
public Timing tickTimer = SpigotTimings.getEntityTimings(this); // Paper
|
||||||
|
+ public Location origin; // Paper
|
||||||
|
// Spigot start
|
||||||
|
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
||||||
|
public final boolean defaultActivationState;
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - Save the entity's origin location
|
||||||
|
+ if (origin != null) {
|
||||||
|
+ nbttagcompound.set("Paper.Origin", this.a(origin.getX(), origin.getY(), origin.getZ()));
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
||||||
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being saved");
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener {
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
+ // Paper start - Restore the entity's origin location
|
||||||
|
+ if (origin == null) {
|
||||||
|
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
|
||||||
|
+ if (!originTag.isEmpty()) {
|
||||||
|
+ origin = new Location(world.getWorld(), originTag.e(0), originTag.e(1), originTag.e(2));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||||
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||||
|
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
||||||
|
this.block = Blocks.SAND.getBlockData();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
||||||
|
+ if (nbttagcompound.hasKey("SourceLoc_x")) {
|
||||||
|
+ int srcX = nbttagcompound.getInt("SourceLoc_x");
|
||||||
|
+ int srcY = nbttagcompound.getInt("SourceLoc_y");
|
||||||
|
+ int srcZ = nbttagcompound.getInt("SourceLoc_z");
|
||||||
|
+ origin = new org.bukkit.Location(world.getWorld(), srcX, srcY, srcZ);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(boolean flag) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
||||||
|
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
||||||
|
|
||||||
|
protected void a(NBTTagCompound nbttagcompound) {
|
||||||
|
this.setFuseTicks(nbttagcompound.getShort("Fuse"));
|
||||||
|
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
||||||
|
+ if (nbttagcompound.hasKey("SourceLoc_x")) {
|
||||||
|
+ int srcX = nbttagcompound.getInt("SourceLoc_x");
|
||||||
|
+ int srcY = nbttagcompound.getInt("SourceLoc_y");
|
||||||
|
+ int srcZ = nbttagcompound.getInt("SourceLoc_z");
|
||||||
|
+ origin = new org.bukkit.Location(world.getWorld(), srcX, srcY, srcZ);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityLiving getSource() {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/World.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/World.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
||||||
|
int j = MathHelper.floor(entity.locZ / 16.0D);
|
||||||
|
boolean flag = entity.attachedToPlayer;
|
||||||
|
|
||||||
|
+ // Paper start - Set origin location when the entity is being added to the world
|
||||||
|
+ if (entity.origin == null) {
|
||||||
|
+ entity.origin = entity.getBukkitEntity().getLocation();
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
if (entity instanceof EntityHuman) {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
|
return spigot;
|
||||||
|
}
|
||||||
|
// Spigot end
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public Location getOrigin() {
|
||||||
|
+ return getHandle().origin;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftFallingSand extends CraftEntity implements FallingSand {
|
||||||
|
public void setHurtEntities(boolean hurtEntities) {
|
||||||
|
getHandle().hurtEntities = hurtEntities;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public org.bukkit.Location getSourceLoc() {
|
||||||
|
+ return getOrigin();
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public org.bukkit.Location getSourceLoc() {
|
||||||
|
+ return getOrigin();
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
--
|
|
@ -1,265 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Byteflux <byte@byteflux.net>
|
|
||||||
Date: Tue, 1 Mar 2016 23:45:08 -0600
|
|
||||||
Subject: [PATCH] FallingBlock and TNTPrimed source location API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
||||||
@@ -0,0 +0,0 @@ public class BlockDragonEgg extends Block {
|
|
||||||
byte b0 = 32;
|
|
||||||
|
|
||||||
if (!BlockFalling.instaFall && world.areChunksLoadedBetween(blockposition.a(-b0, -b0, -b0), blockposition.a(b0, b0, b0))) {
|
|
||||||
- world.addEntity(new EntityFallingBlock(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), this.getBlockData()));
|
|
||||||
+ // Paper start - Add FallingBlock source location API
|
|
||||||
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F));
|
|
||||||
+ world.addEntity(new EntityFallingBlock(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), this.getBlockData()));
|
|
||||||
+ // Paper end
|
|
||||||
} else {
|
|
||||||
world.setAir(blockposition);
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockFalling.java b/src/main/java/net/minecraft/server/BlockFalling.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/BlockFalling.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockFalling.java
|
|
||||||
@@ -0,0 +0,0 @@ public class BlockFalling extends Block {
|
|
||||||
|
|
||||||
if (!BlockFalling.instaFall && world.areChunksLoadedBetween(blockposition.a(-b0, -b0, -b0), blockposition.a(b0, b0, b0))) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
- EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, world.getType(blockposition));
|
|
||||||
+ // Paper start - Add FallingBlock source location
|
|
||||||
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F));
|
|
||||||
+ EntityFallingBlock entityfallingblock = new EntityFallingBlock(loc, world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, world.getType(blockposition));
|
|
||||||
+ // Paper end
|
|
||||||
|
|
||||||
this.a(entityfallingblock);
|
|
||||||
world.addEntity(entityfallingblock);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/BlockTNT.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
|
|
||||||
@@ -0,0 +0,0 @@ public class BlockTNT extends Block {
|
|
||||||
|
|
||||||
public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource());
|
|
||||||
+ org.bukkit.Location loc = explosion.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) explosion.source).sourceLoc : new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); // Paper
|
|
||||||
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource()); // Paper - Add loc
|
|
||||||
|
|
||||||
entitytntprimed.setFuseTicks((short) (world.random.nextInt(entitytntprimed.getFuseTicks() / 4) + entitytntprimed.getFuseTicks() / 8));
|
|
||||||
world.addEntity(entitytntprimed);
|
|
||||||
@@ -0,0 +0,0 @@ public class BlockTNT extends Block {
|
|
||||||
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) {
|
|
||||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving);
|
|
||||||
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); // Paper
|
|
||||||
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving); // Paper - Add loc
|
|
||||||
|
|
||||||
world.addEntity(entitytntprimed);
|
|
||||||
world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gj, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/DispenserRegistry.java b/src/main/java/net/minecraft/server/DispenserRegistry.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/DispenserRegistry.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/DispenserRegistry.java
|
|
||||||
@@ -0,0 +0,0 @@ public class DispenserRegistry {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null);
|
|
||||||
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(block.getLocation(), world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); // Paper - Add source loc
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
world.addEntity(entitytntprimed);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
|
||||||
private float fallHurtAmount = 2.0F;
|
|
||||||
public NBTTagCompound tileEntityData;
|
|
||||||
protected static final DataWatcherObject<BlockPosition> d = DataWatcher.a(EntityFallingBlock.class, DataWatcherRegistry.j);
|
|
||||||
+ public org.bukkit.Location sourceLoc; // Paper
|
|
||||||
|
|
||||||
+ // Paper start - FallingBlock source location API
|
|
||||||
public EntityFallingBlock(World world) {
|
|
||||||
+ this(null, world);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public EntityFallingBlock(org.bukkit.Location loc, World world) {
|
|
||||||
super(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityFallingBlock(World world, double d0, double d1, double d2, IBlockData iblockdata) {
|
|
||||||
+ this(null, world, d0, d1, d2, iblockdata);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public EntityFallingBlock(org.bukkit.Location loc, World world, double d0, double d1, double d2, IBlockData iblockdata) {
|
|
||||||
super(world);
|
|
||||||
+ sourceLoc = loc;
|
|
||||||
+ // Paper end
|
|
||||||
this.block = iblockdata;
|
|
||||||
this.i = true;
|
|
||||||
this.setSize(0.98F, 0.98F);
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
|
||||||
nbttagcompound.set("TileEntityData", this.tileEntityData);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start - Add FallingBlock source location API
|
|
||||||
+ if (sourceLoc != null) {
|
|
||||||
+ nbttagcompound.setInt("SourceLoc_x", sourceLoc.getBlockX());
|
|
||||||
+ nbttagcompound.setInt("SourceLoc_y", sourceLoc.getBlockY());
|
|
||||||
+ nbttagcompound.setInt("SourceLoc_z", sourceLoc.getBlockZ());
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void a(NBTTagCompound nbttagcompound) {
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
|
||||||
this.block = Blocks.SAND.getBlockData();
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start - Add FallingBlock source location API
|
|
||||||
+ if (nbttagcompound.hasKey("SourceLoc_x")) {
|
|
||||||
+ int srcX = nbttagcompound.getInt("SourceLoc_x");
|
|
||||||
+ int srcY = nbttagcompound.getInt("SourceLoc_y");
|
|
||||||
+ int srcZ = nbttagcompound.getInt("SourceLoc_z");
|
|
||||||
+ sourceLoc = new org.bukkit.Location(world.getWorld(), srcX, srcY, srcZ);
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
public void a(boolean flag) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
|
||||||
private int c;
|
|
||||||
public float yield = 4; // CraftBukkit - add field
|
|
||||||
public boolean isIncendiary = false; // CraftBukkit - add field
|
|
||||||
+ public org.bukkit.Location sourceLoc; // Paper - TNT soure location API
|
|
||||||
|
|
||||||
+ // Paper start - TNT source location API
|
|
||||||
public EntityTNTPrimed(World world) {
|
|
||||||
+ this(null, world);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public EntityTNTPrimed(org.bukkit.Location loc, World world) {
|
|
||||||
super(world);
|
|
||||||
+ sourceLoc = loc;
|
|
||||||
+ // Paper end
|
|
||||||
this.c = 80;
|
|
||||||
this.i = true;
|
|
||||||
this.setSize(0.98F, 0.98F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
|
||||||
- this(world);
|
|
||||||
+ this(null, world, d0, d1, d2, entityliving);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public EntityTNTPrimed(org.bukkit.Location loc, World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
|
||||||
+ this(loc, world);
|
|
||||||
this.setPosition(d0, d1, d2);
|
|
||||||
float f = (float) (Math.random() * 6.2831854820251465D);
|
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
|
||||||
|
|
||||||
protected void b(NBTTagCompound nbttagcompound) {
|
|
||||||
nbttagcompound.setShort("Fuse", (short) this.getFuseTicks());
|
|
||||||
+ // Paper start - TNT source location API
|
|
||||||
+ if (sourceLoc != null) {
|
|
||||||
+ nbttagcompound.setInt("SourceLoc_x", sourceLoc.getBlockX());
|
|
||||||
+ nbttagcompound.setInt("SourceLoc_y", sourceLoc.getBlockY());
|
|
||||||
+ nbttagcompound.setInt("SourceLoc_z", sourceLoc.getBlockZ());
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void a(NBTTagCompound nbttagcompound) {
|
|
||||||
this.setFuseTicks(nbttagcompound.getShort("Fuse"));
|
|
||||||
+ // Paper start - TNT source location API
|
|
||||||
+ if (nbttagcompound.hasKey("SourceLoc_x")) {
|
|
||||||
+ int srcX = nbttagcompound.getInt("SourceLoc_x");
|
|
||||||
+ int srcY = nbttagcompound.getInt("SourceLoc_y");
|
|
||||||
+ int srcZ = nbttagcompound.getInt("SourceLoc_z");
|
|
||||||
+ sourceLoc = new org.bukkit.Location(world.getWorld(), srcX, srcY, srcZ);
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityLiving getSource() {
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
||||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
|
||||||
double y = location.getBlockY() + 0.5;
|
|
||||||
double z = location.getBlockZ() + 0.5;
|
|
||||||
|
|
||||||
- EntityFallingBlock entity = new EntityFallingBlock(world, x, y, z, net.minecraft.server.Block.getById(material.getId()).fromLegacyData(data));
|
|
||||||
+ // Paper start - Add FallingBlock source location API
|
|
||||||
+ location = location.clone();
|
|
||||||
+ EntityFallingBlock entity = new EntityFallingBlock(location, world, x, y, z, net.minecraft.server.Block.getById(material.getId()).fromLegacyData(data));
|
|
||||||
+ // Paper end
|
|
||||||
entity.ticksLived = 1;
|
|
||||||
|
|
||||||
world.addEntity(entity, SpawnReason.CUSTOM);
|
|
||||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
|
||||||
int type = CraftMagicNumbers.getId(blockData.getBlock());
|
|
||||||
int data = blockData.getBlock().toLegacyData(blockData);
|
|
||||||
|
|
||||||
- entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.Block.getById(type).fromLegacyData(data));
|
|
||||||
+ // Paper start - Add FallingBlock source location API
|
|
||||||
+ location = location.clone();
|
|
||||||
+ entity = new EntityFallingBlock(location, world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.Block.getById(type).fromLegacyData(data));
|
|
||||||
+ // Paper end
|
|
||||||
} else if (Projectile.class.isAssignableFrom(clazz)) {
|
|
||||||
if (Snowball.class.isAssignableFrom(clazz)) {
|
|
||||||
entity = new EntitySnowball(world, x, y, z);
|
|
||||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
|
||||||
throw new IllegalArgumentException("Cannot spawn hanging entity for " + clazz.getName() + " at " + location);
|
|
||||||
}
|
|
||||||
} else if (TNTPrimed.class.isAssignableFrom(clazz)) {
|
|
||||||
- entity = new EntityTNTPrimed(world, x, y, z, null);
|
|
||||||
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), x, y, z); // Paper
|
|
||||||
+ entity = new EntityTNTPrimed(loc, world, x, y, z, null);
|
|
||||||
} else if (ExperienceOrb.class.isAssignableFrom(clazz)) {
|
|
||||||
entity = new EntityExperienceOrb(world, x, y, z, 0);
|
|
||||||
} else if (Weather.class.isAssignableFrom(clazz)) {
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
||||||
@@ -0,0 +0,0 @@ public class CraftFallingSand extends CraftEntity implements FallingSand {
|
|
||||||
public void setHurtEntities(boolean hurtEntities) {
|
|
||||||
getHandle().hurtEntities = hurtEntities;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // Paper start - Add FallingBlock source location API
|
|
||||||
+ @Override
|
|
||||||
+ public org.bukkit.Location getSourceLoc() {
|
|
||||||
+ return getHandle().sourceLoc;
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
||||||
@@ -0,0 +0,0 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // Paper start
|
|
||||||
+ @Override
|
|
||||||
+ public org.bukkit.Location getSourceLoc() {
|
|
||||||
+ return getHandle().sourceLoc;
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
--
|
|
Loading…
Reference in a new issue