13
0
geforkt von Mirrors/Paper

Code cleanup, fixed doors, chunk entity fetching

By: Tahg <tahgtahv@gmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2011-03-11 16:25:35 -05:00
Ursprung ff806bfa66
Commit a7ed1c966b
9 geänderte Dateien mit 36 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -73,7 +73,9 @@ public class CraftChunk implements Chunk {
} }
Entity[] entities = new Entity[count]; Entity[] entities = new Entity[count];
for (int i = 0; i < 8; i++) { 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(); entities[index++] = entity.getBukkitEntity();
} }
} }
@ -84,7 +86,9 @@ public class CraftChunk implements Chunk {
int index = 0; int index = 0;
net.minecraft.server.Chunk chunk = getHandle(); net.minecraft.server.Chunk chunk = getHandle();
BlockState[] entities = new BlockState[chunk.l.size()]; 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(); entities[index++] = worldServer.getWorld().getBlockAt(position.a, position.b, position.c).getState();
} }
return entities; return entities;

Datei anzeigen

@ -118,7 +118,7 @@ public final class CraftServer implements Server {
found = player; found = player;
delta = curDelta; delta = curDelta;
} }
if(curDelta == 0) break; if (curDelta == 0) break;
} }
} }
return found; return found;

Datei anzeigen

@ -155,7 +155,7 @@ public class CraftWorld implements World {
net.minecraft.server.Chunk chunk = null; net.minecraft.server.Chunk chunk = null;
if(provider.c == null) { if (provider.c == null) {
chunk = provider.b; chunk = provider.b;
} else { } else {
chunk = provider.c.b(x, z); chunk = provider.c.b(x, z);
@ -169,7 +169,7 @@ public class CraftWorld implements World {
} }
public boolean refreshChunk(int x, int z) { public boolean refreshChunk(int x, int z) {
if(!isChunkLoaded(x, z)) { if (!isChunkLoaded(x, z)) {
return false; return false;
} }

Datei anzeigen

@ -92,7 +92,7 @@ public class CraftBlock implements Block {
} }
public void setData(final byte data, boolean applyPhysics) { public void setData(final byte data, boolean applyPhysics) {
if(applyPhysics) { if (applyPhysics) {
chunk.getHandle().d.c(x, y, z, data); chunk.getHandle().d.c(x, y, z, data);
} else { } else {
chunk.getHandle().d.d(x, y, z, data); 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) { public boolean setTypeId(final int type, final boolean applyPhysics) {
if(applyPhysics) { if (applyPhysics) {
return setTypeId(type); return setTypeId(type);
} else { } else {
return chunk.getHandle().d.setTypeId(x, y, z, type); 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) { 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); return chunk.getHandle().d.b(x, y, z, type, data);
} else { } else {
return chunk.getHandle().d.setTypeIdAndData(x, y, z, type, data); return chunk.getHandle().d.setTypeIdAndData(x, y, z, type, data);
@ -383,12 +383,12 @@ public class CraftBlock implements Block {
int power = 0; int power = 0;
BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE; BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE;
net.minecraft.server.World world = chunk.getHandle().d; 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.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.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.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.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.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.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; return face == BlockFace.SELF ? power - 1 : power;
} }

Datei anzeigen

@ -61,7 +61,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public double getEyeHeight(boolean ignoreSneaking) { public double getEyeHeight(boolean ignoreSneaking) {
if(ignoreSneaking) { if (ignoreSneaking) {
return 1.62D; return 1.62D;
} else { } else {
if (isSneaking()) { if (isSneaking()) {

Datei anzeigen

@ -19,7 +19,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public boolean setPassenger(Entity passenger) { public boolean setPassenger(Entity passenger) {
if(passenger instanceof CraftEntity){ if (passenger instanceof CraftEntity){
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle()); ((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
return true; return true;
} else { } else {

Datei anzeigen

@ -25,7 +25,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
public void run() { public void run() {
synchronized(this) { synchronized(this) {
if(cancelled) { if (cancelled) {
return; return;
} }
running = true; 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 { public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
synchronized(this) { synchronized(this) {
if(isDone()) { if (isDone()) {
return getResult(); return getResult();
} }
this.wait(TimeUnit.MILLISECONDS.convert(timeout, unit)); this.wait(TimeUnit.MILLISECONDS.convert(timeout, unit));
@ -60,10 +60,10 @@ public class CraftFuture<T> implements Runnable, Future<T> {
} }
public T getResult() throws ExecutionException { public T getResult() throws ExecutionException {
if(cancelled) { if (cancelled) {
throw new CancellationException(); throw new CancellationException();
} }
if(e!=null) { if (e!=null) {
throw new ExecutionException(e); throw new ExecutionException(e);
} }
return returnStore.getObject(); return returnStore.getObject();
@ -83,14 +83,14 @@ public class CraftFuture<T> implements Runnable, Future<T> {
public boolean cancel(boolean mayInterruptIfRunning) { public boolean cancel(boolean mayInterruptIfRunning) {
synchronized(this) { synchronized(this) {
if(cancelled) { if (cancelled) {
return false; return false;
} }
cancelled = true; cancelled = true;
if(taskId!=-1) { if (taskId!=-1) {
craftScheduler.cancelTask(taskId); craftScheduler.cancelTask(taskId);
} }
if(!running && !done) { if (!running && !done) {
return true; return true;
} else { } else {
return false; return false;

Datei anzeigen

@ -13,9 +13,9 @@ public class LongHashtable<V> extends LongHash
public void put(int msw, int lsw, V value) { public void put(int msw, int lsw, V value) {
put(toLong(msw, lsw), value); put(toLong(msw, lsw), value);
if(value instanceof Chunk) { if (value instanceof Chunk) {
Chunk c = (Chunk)value; 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 + ")"); MinecraftServer.a.info("Chunk (" + c.j + ", " + c.k +") stored at (" + msw + ", " + lsw + ")");
Throwable x = new Throwable(); Throwable x = new Throwable();
x.fillInStackTrace(); x.fillInStackTrace();
@ -26,9 +26,9 @@ public class LongHashtable<V> extends LongHash
public V get(int msw, int lsw) { public V get(int msw, int lsw) {
V value = get(toLong(msw, lsw)); V value = get(toLong(msw, lsw));
if(value instanceof Chunk) { if (value instanceof Chunk) {
Chunk c = (Chunk)value; 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 + ")"); MinecraftServer.a.info("Chunk (" + c.j + ", " + c.k +") stored at (" + msw + ", " + lsw + ")");
Throwable x = new Throwable(); Throwable x = new Throwable();
x.fillInStackTrace(); x.fillInStackTrace();

Datei anzeigen

@ -100,13 +100,13 @@ public class SoftMap<K,V> {
private V fastGet(K key) { private V fastGet(K key) {
SoftMapReference<K,V> ref = map.get(key); SoftMapReference<K,V> ref = map.get(key);
if(ref==null) { if (ref==null) {
return null; return null;
} }
V value = ref.get(); V value = ref.get();
if(value!=null) { if (value!=null) {
strongReferenceQueue.addFirst(value); strongReferenceQueue.addFirst(value);
if(strongReferenceQueue.size() > strongReferenceSize) { if (strongReferenceQueue.size() > strongReferenceSize) {
strongReferenceQueue.removeLast(); strongReferenceQueue.removeLast();
} }
} }
@ -146,7 +146,7 @@ public class SoftMap<K,V> {
private void fastPut(K key, V value) { private void fastPut(K key, V value) {
map.put(key, new SoftMapReference<K,V>(key, value, queue)); map.put(key, new SoftMapReference<K,V>(key, value, queue));
strongReferenceQueue.addFirst(value); strongReferenceQueue.addFirst(value);
if(strongReferenceQueue.size() > strongReferenceSize) { if (strongReferenceQueue.size() > strongReferenceSize) {
strongReferenceQueue.removeLast(); strongReferenceQueue.removeLast();
} }
} }
@ -167,7 +167,7 @@ public class SoftMap<K,V> {
public V remove(K key) { public V remove(K key) {
emptyQueue(); emptyQueue();
SoftMapReference<K,V> ref = map.remove(key); SoftMapReference<K,V> ref = map.remove(key);
if(ref != null) { if (ref != null) {
return ref.get(); return ref.get();
} }
return null; return null;