From 29264350c4bd9a295ac775ca071d4c7b8f918e12 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Sat, 28 Mar 2015 13:46:23 -0700 Subject: [PATCH] Perf: Visualizations --- .../GriefPrevention/Visualization.java | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/Visualization.java b/src/me/ryanhamshire/GriefPrevention/Visualization.java index 1b02e41..7ad7fb3 100644 --- a/src/me/ryanhamshire/GriefPrevention/Visualization.java +++ b/src/me/ryanhamshire/GriefPrevention/Visualization.java @@ -174,64 +174,54 @@ public class Visualization //that will be added later for only the visualization elements within visualization range //locality - int minx = locality.getBlockX() - 100; - int minz = locality.getBlockZ() - 100; - int maxx = locality.getBlockX() + 100; - int maxz = locality.getBlockZ() + 100; + int minx = locality.getBlockX() - 75; + int minz = locality.getBlockZ() - 75; + int maxx = locality.getBlockX() + 75; + int maxz = locality.getBlockZ() + 75; final int STEP = 10; //top line + newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); + newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0)); for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP) { if(x > minx && x < maxx) newElements.add(new VisualizationElement(new Location(world, x, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0)); } + newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0)); //bottom line - for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP) + newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0)); + for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP) { if(x > minx && x < maxx) newElements.add(new VisualizationElement(new Location(world, x, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0)); } + newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0)); //left line + newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); + newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); for(int z = smallz + STEP; z < bigz - STEP / 2; z += STEP) { if(z > minz && z < maxz) newElements.add(new VisualizationElement(new Location(world, smallx, 0, z), accentMaterial, (byte)0, Material.AIR, (byte)0)); } - + newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); + //right line + newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); + newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); for(int z = smallz + STEP; z < bigz - STEP / 2; z += STEP) { if(z > minz && z < maxz) newElements.add(new VisualizationElement(new Location(world, bigx, 0, z), accentMaterial, (byte)0, Material.AIR, (byte)0)); } - - //bottom left corner leaves - newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0)); - newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); - - //bottom right corner leaves - newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0)); - newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); - - //top right corner leaves - newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, bigx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); - - //top left corner leaves - newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0)); - newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); - - //corners - newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); - newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, bigx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); - newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); - - //remove any out of range elements (the corners may be out of range) + + //remove any out of range elements this.removeElementsOutOfRange(newElements, minx, minz, maxx, maxz); //remove any elements outside the claim @@ -249,6 +239,7 @@ public class Visualization { Location tempLocation = element.location; element.location = getVisibleLocation(tempLocation.getWorld(), tempLocation.getBlockX(), height, tempLocation.getBlockZ(), waterIsTransparent); + height = element.location.getBlockY(); element.realMaterial = element.location.getBlock().getType(); element.realData = element.location.getBlock().getData(); }