summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2011-03-11 16:25:35 -0500
committerTahg <tahgtahv@gmail.com>2011-03-11 16:25:35 -0500
commit078f48c0fb18a9b1afb35e094cccbb071007b870 (patch)
treec72f08a674d30d3a8a94bbf2faf68bd4fb224182
parent786fdfb9fed75ebabfb4648a824ff39de91fbc35 (diff)
downloadcraftbukkit-078f48c0fb18a9b1afb35e094cccbb071007b870.tar
craftbukkit-078f48c0fb18a9b1afb35e094cccbb071007b870.tar.gz
craftbukkit-078f48c0fb18a9b1afb35e094cccbb071007b870.tar.lz
craftbukkit-078f48c0fb18a9b1afb35e094cccbb071007b870.tar.xz
craftbukkit-078f48c0fb18a9b1afb35e094cccbb071007b870.zip
Code cleanup, fixed doors, chunk entity fetching
-rw-r--r--src/main/java/net/minecraft/server/BlockBloodStone.java6
-rw-r--r--src/main/java/net/minecraft/server/BlockDoor.java11
-rw-r--r--src/main/java/net/minecraft/server/BlockPumpkin.java6
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneWire.java6
-rw-r--r--src/main/java/net/minecraft/server/BlockSign.java6
-rw-r--r--src/main/java/net/minecraft/server/ChunkProviderServer.java4
-rw-r--r--src/main/java/net/minecraft/server/EntityTrackerEntry.java4
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftChunk.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java18
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java14
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/SoftMap.java10
17 files changed, 61 insertions, 52 deletions
diff --git a/src/main/java/net/minecraft/server/BlockBloodStone.java b/src/main/java/net/minecraft/server/BlockBloodStone.java
index 4134fe45..9a3c9efc 100644
--- a/src/main/java/net/minecraft/server/BlockBloodStone.java
+++ b/src/main/java/net/minecraft/server/BlockBloodStone.java
@@ -10,9 +10,9 @@ public class BlockBloodStone extends Block {
super(i, j, Material.STONE);
}
- //Craftbukkit start
+ // Craftbukkit start
public void a(World world, int i, int j, int k, int l) {
- if(net.minecraft.server.Block.byId[l].c()) {
+ if (net.minecraft.server.Block.byId[l].c()) {
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);
@@ -21,5 +21,5 @@ public class BlockBloodStone extends Block {
server.getPluginManager().callEvent(eventRedstone);
}
}
- //Craftbukkit end
+ // Craftbukkit end
}
diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java
index 189cc311..53f9e803 100644
--- a/src/main/java/net/minecraft/server/BlockDoor.java
+++ b/src/main/java/net/minecraft/server/BlockDoor.java
@@ -171,15 +171,18 @@ public class BlockDoor extends Block {
} else if (l > 0 && Block.byId[l].c()) {
boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k);
- //Craftbukkit start
+ // Craftbukkit start
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);
+ org.bukkit.block.Block blockTop = craftWorld.getBlockAt(i, j + 1, k);
int power = block.getBlockPower();
- BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, flag1 ? 15 : 0);
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, power);
server.getPluginManager().callEvent(eventRedstone);
- this.a(world, i, j, k, eventRedstone.getNewCurrent());
- //Craftbukkit end
+ this.a(world, i, j, k, eventRedstone.getNewCurrent() > 0);
+ // Craftbukkit end
}
}
}
diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java
index 937a03ba..594e4850 100644
--- a/src/main/java/net/minecraft/server/BlockPumpkin.java
+++ b/src/main/java/net/minecraft/server/BlockPumpkin.java
@@ -51,9 +51,9 @@ public class BlockPumpkin extends Block {
world.c(i, j, k, l);
}
- //Craftbukkit start
+ // Craftbukkit start
public void a(World world, int i, int j, int k, int l) {
- if(net.minecraft.server.Block.byId[l].c()) {
+ if (net.minecraft.server.Block.byId[l].c()) {
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);
@@ -62,5 +62,5 @@ public class BlockPumpkin extends Block {
server.getPluginManager().callEvent(eventRedstone);
}
}
- //Craftbukkit end
+ // Craftbukkit end
}
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
index 88dda17b..1524781e 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
@@ -262,7 +262,7 @@ public class BlockRedstoneWire extends Block {
}
}
- public int g(World world, int i, int j, int k, int l) { //Craftbukkit made public
+ public int g(World world, int i, int j, int k, int l) { // Craftbukkit made public
if (world.getTypeId(i, j, k) != this.id) {
return l;
} else {
@@ -280,7 +280,9 @@ public class BlockRedstoneWire extends Block {
if (!flag) {
this.b_(world, i, j, k, i1);
world.e(i, j, k, 0);
- } else if((Block.byId[l] != null && Block.byId[l].c()) || Block.DIODE_OFF.id == l && Block.DIODE_ON.id == l) { //condition added by Craftbukkit
+ } else
+ // Craftbukkit
+ if ((Block.byId[l] != null && Block.byId[l].c()) || Block.DIODE_OFF.id == l && Block.DIODE_ON.id == l) {
this.g(world, i, j, k);
}
diff --git a/src/main/java/net/minecraft/server/BlockSign.java b/src/main/java/net/minecraft/server/BlockSign.java
index 48747867..49b3f176 100644
--- a/src/main/java/net/minecraft/server/BlockSign.java
+++ b/src/main/java/net/minecraft/server/BlockSign.java
@@ -105,8 +105,8 @@ public class BlockSign extends BlockContainer {
super.a(world, i, j, k, l);
- //Craftbukkit start
- if(net.minecraft.server.Block.byId[l].c()) {
+ // Craftbukkit start
+ if (net.minecraft.server.Block.byId[l].c()) {
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Block block = craftWorld.getBlockAt(i, j, k);
@@ -114,6 +114,6 @@ public class BlockSign extends BlockContainer {
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
server.getPluginManager().callEvent(eventRedstone);
}
- //Craftbukkit end
+ // Craftbukkit end
}
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index a7932c3b..b6a8052b 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -109,8 +109,8 @@ public class ChunkProviderServer implements IChunkProvider {
Chunk chunk = (Chunk) this.e.get(i, j); // CraftBukkit
chunk = chunk == null ? (this.g.r ? this.d(i, j) : this.b) : chunk;
- if(chunk == this.b) return chunk;
- if(i != chunk.j || j != chunk.k) {
+ if (chunk == this.b) return chunk;
+ if (i != chunk.j || j != chunk.k) {
MinecraftServer.a.info("Chunk (" + chunk.j + ", " + chunk.k +") stored at (" + i + ", " + j + ")");
MinecraftServer.a.info(chunk.getClass().getName());
Throwable x = new Throwable();
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index e38f5b01..97ba0436 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -71,10 +71,10 @@ public class EntityTrackerEntry {
boolean flag = Math.abs(i) >= 8 || Math.abs(j) >= 8 || Math.abs(k) >= 8;
boolean flag1 = Math.abs(l - this.g) >= 8 || Math.abs(i1 - this.h) >= 8;
- //CraftBukkit - Create relative movement packet only if distance is greater than zero.
+ // CraftBukkit - Create relative movement packet only if distance is greater than zero.
int distanceSquared = j1*j1+k1*k1+l1*l1;
flag = (distanceSquared > 0) && flag;
- //CraftBukkit stop
+ // CraftBukkit stop
if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128) {
if (flag && flag1) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 8127ac03..5898919e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -204,7 +204,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
server.loadPlugins(); // CraftBukkit
}
- void f() { //CraftBukkit - private -> default
+ void f() { // CraftBukkit - private -> default
a.info("Saving chunks");
// CraftBukkit start
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index ba3fb9d4..08ff697e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -73,7 +73,9 @@ public class CraftChunk implements Chunk {
}
Entity[] entities = new Entity[count];
for (int i = 0; i < 8; i++) {
- for (net.minecraft.server.Entity entity : (net.minecraft.server.Entity[])chunk.m[i].toArray()) {
+ for (Object obj : (net.minecraft.server.Entity[])chunk.m[i].toArray()) {
+ if (!(obj instanceof net.minecraft.server.Entity)) continue;
+ net.minecraft.server.Entity entity = (net.minecraft.server.Entity) obj;
entities[index++] = entity.getBukkitEntity();
}
}
@@ -84,7 +86,9 @@ public class CraftChunk implements Chunk {
int index = 0;
net.minecraft.server.Chunk chunk = getHandle();
BlockState[] entities = new BlockState[chunk.l.size()];
- for (ChunkPosition position : (ChunkPosition[])chunk.l.keySet().toArray()) {
+ for (Object obj : chunk.l.keySet().toArray()) {
+ if (!(obj instanceof ChunkPosition)) continue;
+ ChunkPosition position = (ChunkPosition) obj;
entities[index++] = worldServer.getWorld().getBlockAt(position.a, position.b, position.c).getState();
}
return entities;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index da71e4f0..854cc9c4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -118,7 +118,7 @@ public final class CraftServer implements Server {
found = player;
delta = curDelta;
}
- if(curDelta == 0) break;
+ if (curDelta == 0) break;
}
}
return found;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 19487365..2dda5765 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -155,7 +155,7 @@ public class CraftWorld implements World {
net.minecraft.server.Chunk chunk = null;
- if(provider.c == null) {
+ if (provider.c == null) {
chunk = provider.b;
} else {
chunk = provider.c.b(x, z);
@@ -169,7 +169,7 @@ public class CraftWorld implements World {
}
public boolean refreshChunk(int x, int z) {
- if(!isChunkLoaded(x, z)) {
+ if (!isChunkLoaded(x, z)) {
return false;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index d6d1ebfb..14c62314 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -92,7 +92,7 @@ public class CraftBlock implements Block {
}
public void setData(final byte data, boolean applyPhysics) {
- if(applyPhysics) {
+ if (applyPhysics) {
chunk.getHandle().d.c(x, y, z, data);
} else {
chunk.getHandle().d.d(x, y, z, data);
@@ -128,7 +128,7 @@ public class CraftBlock implements Block {
}
public boolean setTypeId(final int type, final boolean applyPhysics) {
- if(applyPhysics) {
+ if (applyPhysics) {
return setTypeId(type);
} else {
return chunk.getHandle().d.setTypeId(x, y, z, type);
@@ -136,7 +136,7 @@ public class CraftBlock implements Block {
}
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
- if(applyPhysics) {
+ if (applyPhysics) {
return chunk.getHandle().d.b(x, y, z, type, data);
} else {
return chunk.getHandle().d.setTypeIdAndData(x, y, z, type, data);
@@ -383,12 +383,12 @@ public class CraftBlock implements Block {
int power = 0;
BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE;
net.minecraft.server.World world = chunk.getHandle().d;
- if((face == BlockFace.DOWN || face == BlockFace.SELF) && world.i(x, y - 1, z, 0)) power = wire.g(world, x, y - 1, z, power);
- if((face == BlockFace.UP || face == BlockFace.SELF) && world.i(x, y + 1, z, 1)) power = wire.g(world, x, y + 1, z, power);
- if((face == BlockFace.EAST || face == BlockFace.SELF) && world.i(x, y, z - 1, 2)) power = wire.g(world, x, y, z - 1, power);
- if((face == BlockFace.WEST || face == BlockFace.SELF) && world.i(x, y, z + 1, 3)) power = wire.g(world, x, y, z + 1, power);
- if((face == BlockFace.NORTH || face == BlockFace.SELF) && world.i(x - 1, y, z, 4)) power = wire.g(world, x - 1, y, z, power);
- if((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.i(x + 1, y, z, 5)) power = wire.g(world, x + 1, y, z, power);
+ if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.i(x, y - 1, z, 0)) power = wire.g(world, x, y - 1, z, power);
+ if ((face == BlockFace.UP || face == BlockFace.SELF) && world.i(x, y + 1, z, 1)) power = wire.g(world, x, y + 1, z, power);
+ if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.i(x, y, z - 1, 2)) power = wire.g(world, x, y, z - 1, power);
+ if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.i(x, y, z + 1, 3)) power = wire.g(world, x, y, z + 1, power);
+ if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.i(x - 1, y, z, 4)) power = wire.g(world, x - 1, y, z, power);
+ if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.i(x + 1, y, z, 5)) power = wire.g(world, x + 1, y, z, power);
return face == BlockFace.SELF ? power - 1 : power;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index bdaefb3f..1bd194d8 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -61,7 +61,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public double getEyeHeight(boolean ignoreSneaking) {
- if(ignoreSneaking) {
+ if (ignoreSneaking) {
return 1.62D;
} else {
if (isSneaking()) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java
index cec4bc3d..20c52a9d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java
@@ -19,7 +19,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
}
public boolean setPassenger(Entity passenger) {
- if(passenger instanceof CraftEntity){
+ if (passenger instanceof CraftEntity){
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
return true;
} else {
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java
index 0952a2ca..ca596fef 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java
@@ -25,7 +25,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
public void run() {
synchronized(this) {
- if(cancelled) {
+ if (cancelled) {
return;
}
running = true;
@@ -51,7 +51,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
synchronized(this) {
- if(isDone()) {
+ if (isDone()) {
return getResult();
}
this.wait(TimeUnit.MILLISECONDS.convert(timeout, unit));
@@ -60,10 +60,10 @@ public class CraftFuture<T> implements Runnable, Future<T> {
}
public T getResult() throws ExecutionException {
- if(cancelled) {
+ if (cancelled) {
throw new CancellationException();
}
- if(e!=null) {
+ if (e!=null) {
throw new ExecutionException(e);
}
return returnStore.getObject();
@@ -83,14 +83,14 @@ public class CraftFuture<T> implements Runnable, Future<T> {
public boolean cancel(boolean mayInterruptIfRunning) {
synchronized(this) {
- if(cancelled) {
+ if (cancelled) {
return false;
}
cancelled = true;
- if(taskId!=-1) {
+ if (taskId!=-1) {
craftScheduler.cancelTask(taskId);
}
- if(!running && !done) {
+ if (!running && !done) {
return true;
} else {
return false;
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java b/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java
index 1dffee07..bb46c621 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java
@@ -13,9 +13,9 @@ public class LongHashtable<V> extends LongHash
public void put(int msw, int lsw, V value) {
put(toLong(msw, lsw), value);
- if(value instanceof Chunk) {
+ if (value instanceof Chunk) {
Chunk c = (Chunk)value;
- if(msw != c.j || lsw != c.k) {
+ if (msw != c.j || lsw != c.k) {
MinecraftServer.a.info("Chunk (" + c.j + ", " + c.k +") stored at (" + msw + ", " + lsw + ")");
Throwable x = new Throwable();
x.fillInStackTrace();
@@ -26,9 +26,9 @@ public class LongHashtable<V> extends LongHash
public V get(int msw, int lsw) {
V value = get(toLong(msw, lsw));
- if(value instanceof Chunk) {
+ if (value instanceof Chunk) {
Chunk c = (Chunk)value;
- if(msw != c.j || lsw != c.k) {
+ if (msw != c.j || lsw != c.k) {
MinecraftServer.a.info("Chunk (" + c.j + ", " + c.k +") stored at (" + msw + ", " + lsw + ")");
Throwable x = new Throwable();
x.fillInStackTrace();
diff --git a/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java b/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java
index 1b8f6c47..29d6f76f 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java
@@ -100,13 +100,13 @@ public class SoftMap<K,V> {
private V fastGet(K key) {
SoftMapReference<K,V> ref = map.get(key);
- if(ref==null) {
+ if (ref==null) {
return null;
}
V value = ref.get();
- if(value!=null) {
+ if (value!=null) {
strongReferenceQueue.addFirst(value);
- if(strongReferenceQueue.size() > strongReferenceSize) {
+ if (strongReferenceQueue.size() > strongReferenceSize) {
strongReferenceQueue.removeLast();
}
}
@@ -146,7 +146,7 @@ public class SoftMap<K,V> {
private void fastPut(K key, V value) {
map.put(key, new SoftMapReference<K,V>(key, value, queue));
strongReferenceQueue.addFirst(value);
- if(strongReferenceQueue.size() > strongReferenceSize) {
+ if (strongReferenceQueue.size() > strongReferenceSize) {
strongReferenceQueue.removeLast();
}
}
@@ -167,7 +167,7 @@ public class SoftMap<K,V> {
public V remove(K key) {
emptyQueue();
SoftMapReference<K,V> ref = map.remove(key);
- if(ref != null) {
+ if (ref != null) {
return ref.get();
}
return null;