2015-07-14 15:59:57 +00:00
|
|
|
From 15c06856e7b75ae48b44b56200fa2e537dafd218 Mon Sep 17 00:00:00 2001
|
2015-04-17 09:51:46 +00:00
|
|
|
From: Byteflux <byte@byteflux.net>
|
|
|
|
Date: Fri, 17 Apr 2015 02:26:14 -0700
|
|
|
|
Subject: [PATCH] Add FallingBlock source location API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
|
|
index de7ac6f..76a6272 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockDragonEgg.java
|
|
|
|
@@ -28,7 +28,10 @@ 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()));
|
|
|
|
+ // PaperSpigot 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()));
|
|
|
|
+ // PaperSpigot end
|
|
|
|
} else {
|
|
|
|
world.setAir(blockposition);
|
|
|
|
|
2015-04-18 20:14:31 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockFalling.java b/src/main/java/net/minecraft/server/BlockFalling.java
|
|
|
|
index 29f8554..1d952b8 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/BlockFalling.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockFalling.java
|
|
|
|
@@ -36,7 +36,10 @@ 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));
|
|
|
|
+ // PaperSpigot 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));
|
|
|
|
+ EntityFallingBlock entityfallingblock = new EntityFallingBlock(loc, world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, world.getType(blockposition));
|
|
|
|
+ // PaperSpigot end
|
|
|
|
|
|
|
|
this.a(entityfallingblock);
|
|
|
|
world.addEntity(entityfallingblock);
|
2015-04-17 09:51:46 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
index 5931e1d..44219cd 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
@@ -16,13 +16,22 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
private int fallHurtMax = 40;
|
|
|
|
private float fallHurtAmount = 2.0F;
|
|
|
|
public NBTTagCompound tileEntityData;
|
|
|
|
+ public org.bukkit.Location sourceLoc; // PaperSpigot
|
|
|
|
|
|
|
|
+ // PaperSpigot start - Add FallingBlock source location API
|
|
|
|
public EntityFallingBlock(World world) {
|
|
|
|
+ this(null, world);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public EntityFallingBlock(org.bukkit.Location loc, World world) {
|
|
|
|
super(world);
|
|
|
|
+ sourceLoc = loc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- public EntityFallingBlock(World world, double d0, double d1, double d2, IBlockData iblockdata) {
|
|
|
|
+ public EntityFallingBlock(org.bukkit.Location loc, World world, double d0, double d1, double d2, IBlockData iblockdata) {
|
|
|
|
super(world);
|
|
|
|
+ sourceLoc = loc;
|
|
|
|
+ // PaperSpigot end
|
|
|
|
this.block = iblockdata;
|
|
|
|
this.k = true;
|
|
|
|
this.setSize(0.98F, 0.98F);
|
|
|
|
@@ -197,7 +206,13 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
if (this.tileEntityData != null) {
|
|
|
|
nbttagcompound.set("TileEntityData", this.tileEntityData);
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ // PaperSpigot 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());
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(NBTTagCompound nbttagcompound) {
|
|
|
|
@@ -233,7 +248,14 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
if (block == null || block.getMaterial() == Material.AIR) {
|
|
|
|
this.block = Blocks.SAND.getBlockData();
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ // PaperSpigot 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);
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(boolean flag) {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2015-06-27 06:18:29 +00:00
|
|
|
index a5de9aa..ce10832 100644
|
2015-04-17 09:51:46 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2015-06-27 06:18:29 +00:00
|
|
|
@@ -886,7 +886,10 @@ public class CraftWorld implements World {
|
2015-04-17 09:51:46 +00:00
|
|
|
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));
|
|
|
|
+ // PaperSpigot 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));
|
|
|
|
+ // PaperSpigot end
|
|
|
|
entity.ticksLived = 1;
|
|
|
|
|
|
|
|
world.addEntity(entity, SpawnReason.CUSTOM);
|
2015-06-27 06:18:29 +00:00
|
|
|
@@ -921,8 +924,10 @@ public class CraftWorld implements World {
|
2015-04-17 09:51:46 +00:00
|
|
|
IBlockData blockData = world.getType(new BlockPosition(x, y, z));
|
|
|
|
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));
|
|
|
|
+ // PaperSpigot 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));
|
|
|
|
+ // PaperSpigot end
|
|
|
|
} else if (Projectile.class.isAssignableFrom(clazz)) {
|
|
|
|
if (Snowball.class.isAssignableFrom(clazz)) {
|
|
|
|
entity = new EntitySnowball(world, x, y, z);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
|
|
index 788f26b..f2dfedd 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 source location API
|
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.Location getSourceLoc() {
|
|
|
|
+ return getHandle().sourceLoc;
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
--
|
2015-07-14 15:59:57 +00:00
|
|
|
1.9.5.msysgit.1
|
2015-04-17 09:51:46 +00:00
|
|
|
|