2015-09-13 06:29:23 +02:00
|
|
|
From cc5daca1c11aec789248376d581251fbd78ab7eb Mon Sep 17 00:00:00 2001
|
2014-12-01 05:58:25 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
2015-03-08 02:16:09 +01:00
|
|
|
Date: Sun, 8 Mar 2015 04:23:41 -0500
|
2014-12-01 05:58:25 +01:00
|
|
|
Subject: [PATCH] Add TNT source location API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
|
2015-07-31 05:41:53 +02:00
|
|
|
index e151bc5..27ce179 100644
|
2014-12-01 05:58:25 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockTNT.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
|
|
|
|
@@ -29,7 +29,8 @@ public class BlockTNT extends Block {
|
|
|
|
|
|
|
|
public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
|
2015-03-08 02:16:09 +01:00
|
|
|
if (!world.isClientSide) {
|
2015-07-31 05:41:53 +02:00
|
|
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource());
|
2014-12-01 05:58:25 +01:00
|
|
|
+ org.bukkit.Location loc = explosion.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) explosion.source).sourceLoc : new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); // PaperSpigot
|
2015-07-31 05:41:53 +02:00
|
|
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource()); // PaperSpigot - add loc
|
2014-12-01 05:58:25 +01:00
|
|
|
|
|
|
|
entitytntprimed.fuseTicks = world.random.nextInt(entitytntprimed.fuseTicks / 4) + entitytntprimed.fuseTicks / 8;
|
|
|
|
world.addEntity(entitytntprimed);
|
|
|
|
@@ -43,7 +44,8 @@ public class BlockTNT extends Block {
|
|
|
|
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving) {
|
2015-03-08 02:16:09 +01:00
|
|
|
if (!world.isClientSide) {
|
2014-12-01 05:58:25 +01:00
|
|
|
if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) {
|
2015-03-08 02:16:09 +01:00
|
|
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving);
|
2014-12-01 05:58:25 +01:00
|
|
|
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); // PaperSpigot
|
|
|
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), entityliving); // PaperSpigot - add loc
|
|
|
|
|
|
|
|
world.addEntity(entitytntprimed);
|
|
|
|
world.makeSound(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
|
2015-03-08 02:16:09 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/DispenserRegistry.java b/src/main/java/net/minecraft/server/DispenserRegistry.java
|
2015-07-31 05:41:53 +02:00
|
|
|
index f2c78f3..bc07d3d 100644
|
2015-03-08 02:16:09 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/DispenserRegistry.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/DispenserRegistry.java
|
2015-06-27 08:18:29 +02:00
|
|
|
@@ -541,7 +541,7 @@ public class DispenserRegistry {
|
2015-03-08 02:16:09 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-01 05:58:25 +01:00
|
|
|
|
2015-03-08 02:16:09 +01:00
|
|
|
- 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); // PaperSpigot
|
|
|
|
// CraftBukkit end
|
2014-12-01 05:58:25 +01:00
|
|
|
|
2015-03-08 02:16:09 +01:00
|
|
|
world.addEntity(entitytntprimed);
|
2014-12-01 05:58:25 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2015-03-08 02:16:09 +01:00
|
|
|
index 50423eb..1daba4e 100644
|
2014-12-01 05:58:25 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
@@ -8,15 +8,23 @@ public class EntityTNTPrimed extends Entity {
|
|
|
|
private EntityLiving source;
|
|
|
|
public float yield = 4; // CraftBukkit - add field
|
|
|
|
public boolean isIncendiary = false; // CraftBukkit - add field
|
|
|
|
+ public org.bukkit.Location sourceLoc; // PaperSpigot
|
|
|
|
|
|
|
|
+ // PaperSpigot start - TNT source location API
|
|
|
|
public EntityTNTPrimed(World world) {
|
|
|
|
+ this(null, world);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public EntityTNTPrimed(org.bukkit.Location loc, World world) {
|
|
|
|
super(world);
|
2015-03-08 02:16:09 +01:00
|
|
|
+ sourceLoc = loc;
|
|
|
|
+ // PaperSpigot end
|
2014-12-01 05:58:25 +01:00
|
|
|
this.k = true;
|
2015-03-08 02:16:09 +01:00
|
|
|
this.setSize(0.98F, 0.98F);
|
2014-12-01 05:58:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
|
|
|
- this(world);
|
|
|
|
+ public EntityTNTPrimed(org.bukkit.Location loc, World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
|
|
|
+ this(loc, world);
|
|
|
|
this.setPosition(d0, d1, d2);
|
2015-02-23 22:03:10 +01:00
|
|
|
float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
|
2014-12-01 05:58:25 +01:00
|
|
|
|
|
|
|
@@ -96,10 +104,25 @@ public class EntityTNTPrimed extends Entity {
|
|
|
|
|
|
|
|
protected void b(NBTTagCompound nbttagcompound) {
|
|
|
|
nbttagcompound.setByte("Fuse", (byte) this.fuseTicks);
|
|
|
|
+ // PaperSpigot 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());
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(NBTTagCompound nbttagcompound) {
|
|
|
|
this.fuseTicks = nbttagcompound.getByte("Fuse");
|
|
|
|
+ // PaperSpigot 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);
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityLiving getSource() {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2015-09-13 02:57:39 +02:00
|
|
|
index 552f5c3..05b88fd 100644
|
2014-12-01 05:58:25 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2015-06-27 08:18:29 +02:00
|
|
|
@@ -1110,7 +1110,8 @@ public class CraftWorld implements World {
|
2014-12-01 05:58:25 +01:00
|
|
|
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); // PaperSpigot
|
|
|
|
+ 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/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
|
|
index e08ad47..b7e8b4d 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
|
|
@@ -65,4 +65,11 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // PaperSpigot start
|
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.Location getSourceLoc() {
|
|
|
|
+ return getHandle().sourceLoc;
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
--
|
2015-09-13 06:29:23 +02:00
|
|
|
2.5.2
|
2014-12-01 05:58:25 +01:00
|
|
|
|