changeset 2:6e1b14cf27cc tip

Fixes a bug in which the monster can move out of water, destroying the surrounding blocks.
author jrvanwhy <jrvanwhy@curseforge.com>
date Sun, 02 Oct 2011 13:48:44 -0700
parents 81acf2c701fe
children
files src/net/jrvanwhy/watermonster/WaterEntity.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/net/jrvanwhy/watermonster/WaterEntity.java	Sat Sep 24 16:10:26 2011 -0700
+++ b/src/net/jrvanwhy/watermonster/WaterEntity.java	Sun Oct 02 13:48:44 2011 -0700
@@ -28,8 +28,9 @@
 		double closestDist = -1.0;
 
 		for (int i = 0; i < players.length; i++) {
-			if (closestDist < 0.0 ||
-			    players[i].getLocation().distance(location) < closestDist) {
+			if (players[i].getWorld().equals(location.getWorld()) &&
+			    (closestDist < 0.0 ||
+			    players[i].getLocation().distance(location) < closestDist)) {
 				closestPlayer = players[i];
 				closestDist = closestPlayer.getLocation().distance(location);
 			}
@@ -157,6 +158,8 @@
 	}
 
 	private void placeMonster(Location location) {
+		if (!location.getBlock().getType().equals(Material.STATIONARY_WATER))
+			return;
 		position = location;
 		position.getBlock().setType(Material.AIR);
 	}