1
0
forked from xjboss/KCauldronX

Return empty chunk in case of null and come back indent for ProcessingQueue, sorry! :)

This commit is contained in:
Prototik 2015-10-22 01:45:44 +07:00
parent c9caa8c770
commit ad909f2788
2 changed files with 102 additions and 102 deletions

View File

@ -250,9 +250,9 @@
+ Chunk chunk = (Chunk) this.loadedChunkHashMap_KC.get(LongHash.toLong(p_73154_1_, p_73154_2_)); + Chunk chunk = (Chunk) this.loadedChunkHashMap_KC.get(LongHash.toLong(p_73154_1_, p_73154_2_));
+ chunk = chunk == null ? (shouldLoadChunk() ? this.loadChunk(p_73154_1_, p_73154_2_) : this.defaultEmptyChunk) : chunk; // Cauldron handle forge server tick events and load the chunk within 5 seconds of the world being loaded (for chunk loaders) + chunk = chunk == null ? (shouldLoadChunk() ? this.loadChunk(p_73154_1_, p_73154_2_) : this.defaultEmptyChunk) : chunk; // Cauldron handle forge server tick events and load the chunk within 5 seconds of the world being loaded (for chunk loaders)
+ +
+ if (chunk == this.defaultEmptyChunk || chunk == null) + if (chunk == defaultEmptyChunk || chunk == null)
+ { + {
+ return chunk; + return defaultEmptyChunk;
+ } + }
+ +
+ if ((p_73154_1_ != chunk.xPosition || p_73154_2_ != chunk.zPosition) && !worldObj.isProfilingWorld()) + if ((p_73154_1_ != chunk.xPosition || p_73154_2_ != chunk.zPosition) && !worldObj.isProfilingWorld())

View File

@ -6,119 +6,119 @@ import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class ProcessingQueue<T> extends QueueWrapper<T> { public class ProcessingQueue<T> extends QueueWrapper<T> {
public class ProcessingIterator implements Iterator<T> { public class ProcessingIterator implements Iterator<T> {
private Iterator<T> mRealIterator = mCollection.iterator(); private Iterator<T> mRealIterator = mCollection.iterator();
@Override @Override
public boolean hasNext() { public boolean hasNext() {
return mRealIterator.hasNext(); return mRealIterator.hasNext();
} }
@Override @Override
public T next() { public T next() {
return mRealIterator.next(); return mRealIterator.next();
} }
@Override @Override
public void remove() { public void remove() {
mRealIterator.remove(); mRealIterator.remove();
mSize.decrementAndGet(); mSize.decrementAndGet();
} }
} }
private final AtomicInteger mSize; private final AtomicInteger mSize;
@Override @Override
public boolean add(T e) { public boolean add(T e) {
boolean result = super.add(e); boolean result = super.add(e);
if (result) { if (result) {
mSize.incrementAndGet(); mSize.incrementAndGet();
} }
return result; return result;
}; };
@Override @Override
public boolean offer(T e) { public boolean offer(T e) {
boolean result = super.offer(e); boolean result = super.offer(e);
if (result) { if (result) {
mSize.incrementAndGet(); mSize.incrementAndGet();
} }
return result; return result;
} }
@Override @Override
public boolean addAll(Collection<? extends T> c) { public boolean addAll(Collection<? extends T> c) {
boolean result = false; boolean result = false;
for (T t : c) { for (T t : c) {
result |= add(t); result |= add(t);
} }
return result; return result;
} }
@Override @Override
public T remove() { public T remove() {
T result = super.remove(); T result = super.remove();
mSize.decrementAndGet(); mSize.decrementAndGet();
return result; return result;
} }
@Override @Override
public boolean remove(Object o) { public boolean remove(Object o) {
boolean result = super.remove(o); boolean result = super.remove(o);
if (result) { if (result) {
mSize.decrementAndGet(); mSize.decrementAndGet();
} }
return result; return result;
} }
@Override @Override
public boolean removeAll(Collection<?> c) { public boolean removeAll(Collection<?> c) {
boolean result = false; boolean result = false;
for (Object t : c) { for (Object t : c) {
result |= remove(t); result |= remove(t);
} }
return result; return result;
} }
@Override @Override
public boolean retainAll(Collection<?> c) { public boolean retainAll(Collection<?> c) {
boolean result = super.retainAll(c); boolean result = super.retainAll(c);
if (result) { if (result) {
mSize.set(mCollection.size()); mSize.set(mCollection.size());
} }
return result; return result;
} }
@Override @Override
public T poll() { public T poll() {
T result = super.remove(); T result = super.remove();
if (result != null) { if (result != null) {
mSize.decrementAndGet(); mSize.decrementAndGet();
} }
return result; return result;
} }
public ProcessingQueue(Queue<T> collection) { public ProcessingQueue(Queue<T> collection) {
super(collection); super(collection);
mSize = new AtomicInteger(collection.size()); mSize = new AtomicInteger(collection.size());
} }
@Override @Override
public ProcessingIterator iterator() { public ProcessingIterator iterator() {
return new ProcessingIterator(); return new ProcessingIterator();
} }
@Override @Override
public String toString() { public String toString() {
if (size() == 0) if (size() == 0)
return "[]"; return "[]";
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (T t : this) { for (T t : this) {
builder.append(','); builder.append(',');
builder.append(t == null ? "null" : t.getClass().getSimpleName()); builder.append(t == null ? "null" : t.getClass().getSimpleName());
} }
builder.setCharAt(0, '['); builder.setCharAt(0, '[');
builder.append(']'); builder.append(']');
return builder.toString(); return builder.toString();
} }
} }