285 lines
16 KiB
Diff
285 lines
16 KiB
Diff
From 17d7dec29d5dbd0e5e5a59452288a8b50a6692e5 Mon Sep 17 00:00:00 2001
|
|
From: Byteflux <byte@byteflux.net>
|
|
Date: Wed, 18 Mar 2015 04:13:49 -0700
|
|
Subject: [PATCH] Add FallingBlock and TNT source location API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
index b1c3f10e5..385225a41 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
@@ -29,7 +29,10 @@ public class BlockDragonEgg extends Block {
|
|
|
|
if (!BlockFalling.instaFall && world.b(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
|
|
// CraftBukkit - added data
|
|
- EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this, world.getData(i, j, k));
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
|
|
+ EntityFallingBlock entityfallingblock = new EntityFallingBlock(loc, world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this, world.getData(i, j, k));
|
|
+ // PaperSpigot end
|
|
|
|
world.addEntity(entityfallingblock);
|
|
} else {
|
|
diff --git a/src/main/java/net/minecraft/server/BlockFalling.java b/src/main/java/net/minecraft/server/BlockFalling.java
|
|
index 473fc3121..07096e8a3 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockFalling.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockFalling.java
|
|
@@ -35,7 +35,10 @@ public class BlockFalling extends Block {
|
|
|
|
if (!instaFall && world.b(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
|
|
if (!world.isStatic) {
|
|
- EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this, world.getData(i, j, k));
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
|
|
+ EntityFallingBlock entityfallingblock = new EntityFallingBlock(loc, world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this, world.getData(i, j, k));
|
|
+ // PaperSpigot 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 35bf1a3cf..9f48d1f14 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockTNT.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
|
|
@@ -30,7 +30,10 @@ public class BlockTNT extends Block {
|
|
|
|
public void wasExploded(World world, int i, int j, int k, Explosion explosion) {
|
|
if (!world.isStatic) {
|
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), explosion.c());
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ org.bukkit.Location loc = explosion.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) explosion.source).sourceLoc : new org.bukkit.Location(world.getWorld(), (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
|
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), explosion.c());
|
|
+ // PaperSpigot end
|
|
|
|
entitytntprimed.fuseTicks = world.random.nextInt(entitytntprimed.fuseTicks / 4) + entitytntprimed.fuseTicks / 8;
|
|
world.addEntity(entitytntprimed);
|
|
@@ -44,7 +47,10 @@ public class BlockTNT extends Block {
|
|
public void a(World world, int i, int j, int k, int l, EntityLiving entityliving) {
|
|
if (!world.isStatic) {
|
|
if ((l & 1) == 1) {
|
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), entityliving);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
|
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), entityliving);
|
|
+ // PaperSpigot end
|
|
|
|
world.addEntity(entitytntprimed);
|
|
world.makeSound(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
|
|
diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java b/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java
|
|
index d9493393a..439e130f5 100644
|
|
--- a/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java
|
|
+++ b/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java
|
|
@@ -42,7 +42,10 @@ final class DispenseBehaviorTNT extends DispenseBehaviorItem {
|
|
}
|
|
}
|
|
|
|
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(loc, world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null);
|
|
+ // PaperSpigot end
|
|
// 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 715f6d0a4..51d25051b 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
@@ -16,20 +16,31 @@ public class EntityFallingBlock extends Entity {
|
|
private int fallHurtMax;
|
|
private float fallHurtAmount;
|
|
public NBTTagCompound tileEntityData;
|
|
+ public org.bukkit.Location sourceLoc; // PaperSpigot
|
|
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
public EntityFallingBlock(World world) {
|
|
+ this(null, world);
|
|
+ }
|
|
+
|
|
+ public EntityFallingBlock(org.bukkit.Location loc, World world) {
|
|
super(world);
|
|
+ sourceLoc = loc;
|
|
+ // PaperSpigot end
|
|
this.dropItem = true;
|
|
this.fallHurtMax = 40;
|
|
this.fallHurtAmount = 2.0F;
|
|
}
|
|
|
|
- public EntityFallingBlock(World world, double d0, double d1, double d2, Block block) {
|
|
- this(world, d0, d1, d2, block, 0);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ public EntityFallingBlock(org.bukkit.Location loc, World world, double d0, double d1, double d2, Block block) {
|
|
+ this(loc, world, d0, d1, d2, block, 0);
|
|
}
|
|
|
|
- public EntityFallingBlock(World world, double d0, double d1, double d2, Block block, int i) {
|
|
+ public EntityFallingBlock(org.bukkit.Location loc, World world, double d0, double d1, double d2, Block block, int i) {
|
|
super(world);
|
|
+ sourceLoc = loc;
|
|
+ // PaperSpigot end
|
|
this.dropItem = true;
|
|
this.fallHurtMax = 40;
|
|
this.fallHurtAmount = 2.0F;
|
|
@@ -203,6 +214,13 @@ public class EntityFallingBlock extends Entity {
|
|
if (this.tileEntityData != null) {
|
|
nbttagcompound.set("TileEntityData", this.tileEntityData);
|
|
}
|
|
+ // PaperSpigot start - Add FallingBlock and 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) {
|
|
@@ -233,6 +251,14 @@ public class EntityFallingBlock extends Entity {
|
|
if (this.id.getMaterial() == Material.AIR) {
|
|
this.id = Blocks.SAND;
|
|
}
|
|
+ // PaperSpigot start - Add FallingBlock and 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 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 5ce67f599..8aa166399 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
@@ -8,16 +8,26 @@ 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 - Add FallingBlock and TNT source location API
|
|
public EntityTNTPrimed(World world) {
|
|
+ this(null, world);
|
|
+ }
|
|
+
|
|
+ public EntityTNTPrimed(org.bukkit.Location loc, World world) {
|
|
super(world);
|
|
+ sourceLoc = loc;
|
|
+ // PaperSpigot end
|
|
this.k = true;
|
|
this.a(0.98F, 0.98F);
|
|
this.height = this.length / 2.0F;
|
|
}
|
|
|
|
- public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
|
- this(world);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ public EntityTNTPrimed(org.bukkit.Location loc, World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
|
+ this(loc, world);
|
|
+ // PaperSpigot end
|
|
this.setPosition(d0, d1, d2);
|
|
//float f = (float) (Math.random() * 3.1415927410125732D * 2.0D); // PaperSpigot - Fix directional TNT bias
|
|
|
|
@@ -93,10 +103,25 @@ public class EntityTNTPrimed extends Entity {
|
|
|
|
protected void b(NBTTagCompound nbttagcompound) {
|
|
nbttagcompound.setByte("Fuse", (byte) this.fuseTicks);
|
|
+ // PaperSpigot start - Add FallingBlock and 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 - Add FallingBlock and 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
|
|
index 4b3f8284b..1babd7979 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -861,7 +861,10 @@ 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()), data);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ location = location.clone();
|
|
+ EntityFallingBlock entity = new EntityFallingBlock(location, world, x, y, z, net.minecraft.server.Block.getById(material.getId()), data);
|
|
+ // PaperSpigot end
|
|
entity.ticksLived = 1;
|
|
|
|
world.addEntity(entity, SpawnReason.CUSTOM);
|
|
@@ -896,7 +899,10 @@ public class CraftWorld implements World {
|
|
int type = world.getTypeId((int) x, (int) y, (int) z);
|
|
int data = world.getData((int) x, (int) y, (int) z);
|
|
|
|
- entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.Block.getById(type), data);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT 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), data);
|
|
+ // PaperSpigot end
|
|
} else if (Projectile.class.isAssignableFrom(clazz)) {
|
|
if (Snowball.class.isAssignableFrom(clazz)) {
|
|
entity = new EntitySnowball(world, x, y, z);
|
|
@@ -1066,7 +1072,10 @@ 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);
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ org.bukkit.Location loc = new org.bukkit.Location(world.getWorld(), x, y, z);
|
|
+ entity = new EntityTNTPrimed(loc, world, x, y, z, null);
|
|
+ // PaperSpigot end
|
|
} 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 d67ddd086..830f5bb6e 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
@@ -47,4 +47,11 @@ public class CraftFallingSand extends CraftEntity implements FallingSand {
|
|
public void setDropItem(boolean drop) {
|
|
getHandle().dropItem = drop;
|
|
}
|
|
+
|
|
+ // PaperSpigot start - Add FallingBlock and TNT source location API
|
|
+ @Override
|
|
+ public org.bukkit.Location getSourceLoc() {
|
|
+ return getHandle().sourceLoc;
|
|
+ }
|
|
+ // PaperSpigot end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
index e08ad471e..d4167b758 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 - Add FallingBlock and TNT source location API
|
|
+ @Override
|
|
+ public org.bukkit.Location getSourceLoc() {
|
|
+ return getHandle().sourceLoc;
|
|
+ }
|
|
+ // PaperSpigot end
|
|
}
|
|
--
|
|
2.13.3
|
|
|