mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Code cleanup, fixed doors, chunk entity fetching
By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
parent
ff806bfa66
commit
a7ed1c966b
@ -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;
|
||||
|
@ -118,7 +118,7 @@ public final class CraftServer implements Server {
|
||||
found = player;
|
||||
delta = curDelta;
|
||||
}
|
||||
if(curDelta == 0) break;
|
||||
if (curDelta == 0) break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user