summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore27
-rw-r--r--src/main/java/net/minecraft/server/BlockPressurePlate.java16
-rw-r--r--src/main/java/net/minecraft/server/BlockSoil.java104
-rw-r--r--src/main/java/net/minecraft/server/Entity.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java8
5 files changed, 125 insertions, 32 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index a841025d..00000000
--- a/.gitignore
+++ /dev/null
@@ -1,27 +0,0 @@
-# Eclipse stuff
-/.classpath
-/.project
-/.settings
-
-# netbeans
-/nbproject
-
-# we use maven!
-/build.xml
-
-# maven
-/target
-
-# vim
-.*.sw[a-p]
-
-# various other potential build files
-/build
-/bin
-/dist
-/manifest.mf
-
-/world
-
-# Mac filesystem dust
-/.DS_Store \ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java
index b5ce1bc6..b48bb22b 100644
--- a/src/main/java/net/minecraft/server/BlockPressurePlate.java
+++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java
@@ -8,8 +8,10 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.Cancellable;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.player.PlayerInteractEvent;
// CraftBukkit end
@@ -99,10 +101,16 @@ public class BlockPressurePlate extends Block {
if (flag != flag1) {
if (flag1) {
for (Object object: list) {
- if (object != null && object instanceof EntityHuman) {
- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null);
-
- if (event.isCancelled()) {
+ if (object != null) {
+ Cancellable cancellable;
+ if (object instanceof EntityHuman) {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null);
+ }
+ else if (object instanceof Entity) {
+ cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), ((WorldServer)world).getWorld().getBlockAt(i, j, k));
+ }
+ else continue;
+ if (cancellable.isCancelled()) {
return;
}
}
diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java
new file mode 100644
index 00000000..f88f7609
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockSoil.java
@@ -0,0 +1,104 @@
+package net.minecraft.server;
+
+import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.entity.EntityInteractEvent;
+
+public class BlockSoil extends Block {
+
+ protected BlockSoil(int i) {
+ super(i, Material.EARTH);
+ this.textureId = 87;
+ this.a(true);
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
+ this.e(255);
+ }
+
+ public AxisAlignedBB d(World world, int i, int j, int k) {
+ return AxisAlignedBB.b((double) (i + 0), (double) (j + 0), (double) (k + 0), (double) (i + 1), (double) (j + 1), (double) (k + 1));
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public int a(int i, int j) {
+ return i == 1 && j > 0 ? this.textureId - 1 : (i == 1 ? this.textureId : 2);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ if (random.nextInt(5) == 0) {
+ if (this.h(world, i, j, k)) {
+ world.c(i, j, k, 7);
+ } else {
+ int l = world.getData(i, j, k);
+
+ if (l > 0) {
+ world.c(i, j, k, l - 1);
+ } else if (!this.g(world, i, j, k)) {
+ world.e(i, j, k, Block.DIRT.id);
+ }
+ }
+ }
+ }
+
+ public void b(World world, int i, int j, int k, Entity entity) {
+ // CraftBukkit start - Interact Soil
+ Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, Action.PHYSICAL, i, j, k, -1, null);
+ }
+ else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), ((WorldServer)world).getWorld().getBlockAt(i, j, k));
+ }
+ if (!cancellable.isCancelled()) {
+ if (world.k.nextInt(4) == 0) {
+ world.e(i, j, k, Block.DIRT.id);
+ }
+ }
+ // Craftbukkit end
+ }
+
+ private boolean g(World world, int i, int j, int k) {
+ byte b0 = 0;
+
+ for (int l = i - b0; l <= i + b0; ++l) {
+ for (int i1 = k - b0; i1 <= k + b0; ++i1) {
+ if (world.getTypeId(l, j + 1, i1) == Block.CROPS.id) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private boolean h(World world, int i, int j, int k) {
+ for (int l = i - 4; l <= i + 4; ++l) {
+ for (int i1 = j; i1 <= j + 1; ++i1) {
+ for (int j1 = k - 4; j1 <= k + 4; ++j1) {
+ if (world.getMaterial(l, i1, j1) == Material.WATER) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public void a(World world, int i, int j, int k, int l) {
+ super.a(world, i, j, k, l);
+ Material material = world.getMaterial(i, j + 1, k);
+
+ if (material.isBuildable()) {
+ world.e(i, j, k, Block.DIRT.id);
+ }
+ }
+
+ public int a(int i, Random random) {
+ return Block.DIRT.a(0, random);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 1012c24d..94e8d019 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -52,7 +52,7 @@ public abstract class Entity {
public float width;
public float bf;
public float bg;
- protected float fallDistance;
+ public float fallDistance; // Craftbukkit made public
private int b;
public double bi;
public double bj;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index a9fc75fb..af535ba2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -238,4 +238,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
getHandle().passenger.setPassengerOf(null);
return true;
}
+
+ public float getFallDistance() {
+ return getHandle().fallDistance;
+ }
+
+ public void setFallDistance(float distance) {
+ getHandle().fallDistance = distance;
+ }
}