3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 04:50:06 +01:00

Add FallingBlock source location API

Dieser Commit ist enthalten in:
Byteflux 2015-04-17 02:51:46 -07:00 committet von Zach Brown
Ursprung 83fc0d21e7
Commit 8bd77dff5a
3 geänderte Dateien mit 237 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,25 @@
From f63d437c04b5a57accd831c20410554f6bc534af Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Fri, 17 Apr 2015 02:43:00 -0700
Subject: [PATCH] Add FallingBlock source location API
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
index 1edd6e0..93b17e3 100644
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
@@ -45,4 +45,11 @@ public interface FallingBlock extends Entity {
* @param drop true to break into an item when obstructed
*/
void setDropItem(boolean drop);
+
+ /**
+ * Gets the source block location of the falling block
+ *
+ * @return the source block location the falling block was spawned from
+ */
+ org.bukkit.Location getSourceLoc(); // PaperSpigot - Add FallingBlock source location API
}
--
1.9.4.msysgit.2

Datei anzeigen

@ -1,9 +1,90 @@
From 3ac4aa5507b3eb96cbd4ce5d01a25c391475f834 Mon Sep 17 00:00:00 2001 From 87f7b6f12d357afe2d1cffc42baaa726e3fbd95d Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com> From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sat, 7 Mar 2015 19:44:29 -0600 Date: Sat, 7 Mar 2015 19:44:29 -0600
Subject: [PATCH] mc-dev imports Subject: [PATCH] mc-dev imports
diff --git a/src/main/java/net/minecraft/server/BlockFalling.java b/src/main/java/net/minecraft/server/BlockFalling.java
new file mode 100644
index 0000000..29f8554
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockFalling.java
@@ -0,0 +1,75 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class BlockFalling extends Block {
+
+ public static boolean instaFall;
+
+ public BlockFalling() {
+ super(Material.SAND);
+ this.a(CreativeModeTab.b);
+ }
+
+ public BlockFalling(Material material) {
+ super(material);
+ }
+
+ public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ world.a(blockposition, (Block) this, this.a(world));
+ }
+
+ public void doPhysics(World world, BlockPosition blockposition, IBlockData iblockdata, Block block) {
+ world.a(blockposition, (Block) this, this.a(world));
+ }
+
+ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ if (!world.isClientSide) {
+ this.f(world, blockposition);
+ }
+
+ }
+
+ private void f(World world, BlockPosition blockposition) {
+ if (canFall(world, blockposition.down()) && blockposition.getY() >= 0) {
+ byte b0 = 32;
+
+ 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));
+
+ this.a(entityfallingblock);
+ world.addEntity(entityfallingblock);
+ }
+ } else {
+ world.setAir(blockposition);
+
+ BlockPosition blockposition1;
+
+ for (blockposition1 = blockposition.down(); canFall(world, blockposition1) && blockposition1.getY() > 0; blockposition1 = blockposition1.down()) {
+ ;
+ }
+
+ if (blockposition1.getY() > 0) {
+ world.setTypeUpdate(blockposition1.up(), this.getBlockData());
+ }
+ }
+
+ }
+ }
+
+ protected void a(EntityFallingBlock entityfallingblock) {}
+
+ public int a(World world) {
+ return 2;
+ }
+
+ public static boolean canFall(World world, BlockPosition blockposition) {
+ Block block = world.getType(blockposition).getBlock();
+ Material material = block.material;
+
+ return block == Blocks.FIRE || material == Material.AIR || material == Material.WATER || material == Material.LAVA;
+ }
+
+ public void a_(World world, BlockPosition blockposition) {}
+}
diff --git a/src/main/java/net/minecraft/server/BlockMinecartTrackAbstract.java b/src/main/java/net/minecraft/server/BlockMinecartTrackAbstract.java diff --git a/src/main/java/net/minecraft/server/BlockMinecartTrackAbstract.java b/src/main/java/net/minecraft/server/BlockMinecartTrackAbstract.java
new file mode 100644 new file mode 100644
index 0000000..0d108eb index 0000000..0d108eb
@ -837,5 +918,5 @@ index 0000000..f75e2de
+ } + }
+} +}
-- --
1.9.1 1.9.4.msysgit.2

Datei anzeigen

@ -0,0 +1,129 @@
From 6a543f6806490bcf2a1ae8aa21db1851fe895316 Mon Sep 17 00:00:00 2001
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);
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
index 6b5800e..f479b50 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -888,7 +888,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()).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);
@@ -923,8 +926,10 @@ public class CraftWorld implements World {
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
}
--
1.9.4.msysgit.2