diff options
author | Wesley Wolfe <weswolf@aol.com> | 2012-08-05 21:36:09 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2012-08-05 21:36:09 -0500 |
commit | f5777cc0b726aa87fa2af245cc57d4e809143638 (patch) | |
tree | e947df0c20bc61658924664e8a874c49c524bbd9 /src | |
parent | 44234c47cedc4226fd118fbffd84866a3320e1af (diff) | |
download | craftbukkit-f5777cc0b726aa87fa2af245cc57d4e809143638.tar craftbukkit-f5777cc0b726aa87fa2af245cc57d4e809143638.tar.gz craftbukkit-f5777cc0b726aa87fa2af245cc57d4e809143638.tar.lz craftbukkit-f5777cc0b726aa87fa2af245cc57d4e809143638.tar.xz craftbukkit-f5777cc0b726aa87fa2af245cc57d4e809143638.zip |
Add Vec3DPool for diff visibility
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/Vec3DPool.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/Vec3DPool.java b/src/main/java/net/minecraft/server/Vec3DPool.java new file mode 100644 index 00000000..1d7e8e1b --- /dev/null +++ b/src/main/java/net/minecraft/server/Vec3DPool.java @@ -0,0 +1,53 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +public class Vec3DPool { + + private final int a; + private final int b; + private final List c = new ArrayList(); + private int d = 0; + private int e = 0; + private int f = 0; + + public Vec3DPool(int i, int j) { + this.a = i; + this.b = j; + } + + public Vec3D create(double d0, double d1, double d2) { + Vec3D vec3d; + + if (this.d >= this.c.size()) { + vec3d = new Vec3D(d0, d1, d2); + this.c.add(vec3d); + } else { + vec3d = (Vec3D) this.c.get(this.d); + vec3d.b(d0, d1, d2); + } + + ++this.d; + return vec3d; + } + + public void a() { + if (this.d > this.e) { + this.e = this.d; + } + + if (this.f++ == this.a) { + int i = Math.max(this.e, this.c.size() - this.b); + + while (this.c.size() > i) { + this.c.remove(i); + } + + this.e = 0; + this.f = 0; + } + + this.d = 0; + } +} |