From b3df1993ca4b396025f111c87175ff8a53e4a78d Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 4 Jan 2017 11:19:02 -0500 Subject: [PATCH] current progress --- src/regions/Main.java | 8 ++++ src/regions/Octree.java | 88 ++++++++++++++++++++++++++++++++++++ src/regions/Owner.java | 17 +++++++ src/regions/RegionEvent.java | 15 ++++++ 4 files changed, 128 insertions(+) create mode 100644 src/regions/Main.java create mode 100644 src/regions/Octree.java create mode 100644 src/regions/Owner.java create mode 100644 src/regions/RegionEvent.java diff --git a/src/regions/Main.java b/src/regions/Main.java new file mode 100644 index 0000000..565b49b --- /dev/null +++ b/src/regions/Main.java @@ -0,0 +1,8 @@ +package regions; + +import org.bukkit.plugin.java.JavaPlugin; + +public class Main extends JavaPlugin +{ + +} diff --git a/src/regions/Octree.java b/src/regions/Octree.java new file mode 100644 index 0000000..cda960a --- /dev/null +++ b/src/regions/Octree.java @@ -0,0 +1,88 @@ +package regions; + +public class Octree +{ + //STATIC + //================================================================== + + public static class Node + { + public final boolean full; + public final Node[] nodes; + + public Node(boolean full) + { + this.full = full; + this.nodes = new Node[0]; + } + + public Node(Node[] nodes) + { + this.full = false; + this.nodes = nodes; + } + + } + + + + private static class IntReference + { + int ref; + + IntReference(int i) + { + this.ref = i; + } + } + + + + private static Node parseBytes(IntReference index, byte[] bytes, int parentByte) + { + if (parentByte == 0b00000010) return new Node(true); + if (parentByte == 0b00000001) return new Node(false); + + byte a = bytes[index.ref++], + b = bytes[index.ref++]; + + return + new Node + ( + new Node[] + { + parseBytes(index, bytes, (a >> 6 & 3)), + parseBytes(index, bytes, (a >> 4 & 3)), + parseBytes(index, bytes, (a >> 2 & 3)), + parseBytes(index, bytes, (a & 3)), + + parseBytes(index, bytes, (b >> 6 & 3)), + parseBytes(index, bytes, (b >> 4 & 3)), + parseBytes(index, bytes, (b >> 2 & 3)), + parseBytes(index, bytes, (b & 3)) + }); + } + + + + public static Node parseBytes(int startAtIndex, byte[] bytes) + { + return parseBytes ( new IntReference(startAtIndex), bytes, 0 ); + } + public static Node parseBytes(byte[] bytes) + { + return parseBytes ( new IntReference(0), bytes, 0 ); + } + + //INSTANCE + //================================================================== + + public final Owner owner; + public final Node root; + + public Octree(Owner owner, byte[] bytes) + { + this.owner = owner; + this.root = parseBytes(bytes); + } +} diff --git a/src/regions/Owner.java b/src/regions/Owner.java new file mode 100644 index 0000000..3440fb6 --- /dev/null +++ b/src/regions/Owner.java @@ -0,0 +1,17 @@ +package regions; + +public class Owner +{ + public final String name; + public final Owner parent; + public final Owner[] children; + public final Octree[] trees; + + public Owner(String name, Owner parent, Owner[] children, Octree[] trees) + { + this.name = name; + this.parent = parent; + this.children = children; + this.trees = trees; + } +} diff --git a/src/regions/RegionEvent.java b/src/regions/RegionEvent.java new file mode 100644 index 0000000..9470fe0 --- /dev/null +++ b/src/regions/RegionEvent.java @@ -0,0 +1,15 @@ +package regions; + +import org.bukkit.event.Event; + +public class RegionEvent +{ + public final T bukkitEvent; + public final Owner region; + + public RegionEvent(T bukkitEvent, Owner region) + { + this.bukkitEvent = bukkitEvent; + this.region = region; + } +}