parent
ee1a5c567b
commit
89f83b5b6a
|
|
@ -27,6 +27,8 @@ import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Lightable;
|
import org.bukkit.block.data.Lightable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
@ -130,23 +132,11 @@ public class Visualization
|
||||||
//handy for combining several visualizations together, as when visualization a top level claim with several subdivisions inside
|
//handy for combining several visualizations together, as when visualization a top level claim with several subdivisions inside
|
||||||
//locality is a performance consideration. only create visualization blocks for around 100 blocks of the locality
|
//locality is a performance consideration. only create visualization blocks for around 100 blocks of the locality
|
||||||
|
|
||||||
private void addClaimElements(Claim claim, int height, VisualizationType visualizationType, Location locality)
|
public void addClaimElements(Claim claim, int height, VisualizationType visualizationType, Location locality)
|
||||||
{
|
{
|
||||||
Location smallXsmallZ = claim.getLesserBoundaryCorner();
|
|
||||||
Location bigXbigZ = claim.getGreaterBoundaryCorner();
|
|
||||||
World world = smallXsmallZ.getWorld();
|
|
||||||
boolean waterIsTransparent = locality.getBlock().getType() == Material.WATER;
|
|
||||||
|
|
||||||
int smallx = smallXsmallZ.getBlockX();
|
|
||||||
int smallz = smallXsmallZ.getBlockZ();
|
|
||||||
int bigx = bigXbigZ.getBlockX();
|
|
||||||
int bigz = bigXbigZ.getBlockZ();
|
|
||||||
|
|
||||||
BlockData cornerBlockData;
|
BlockData cornerBlockData;
|
||||||
BlockData accentBlockData;
|
BlockData accentBlockData;
|
||||||
|
|
||||||
ArrayList<VisualizationElement> newElements = new ArrayList<VisualizationElement>();
|
|
||||||
|
|
||||||
if (visualizationType == VisualizationType.Claim)
|
if (visualizationType == VisualizationType.Claim)
|
||||||
{
|
{
|
||||||
cornerBlockData = Material.GLOWSTONE.createBlockData();
|
cornerBlockData = Material.GLOWSTONE.createBlockData();
|
||||||
|
|
@ -174,6 +164,21 @@ public class Visualization
|
||||||
accentBlockData = Material.NETHERRACK.createBlockData();
|
accentBlockData = Material.NETHERRACK.createBlockData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addClaimElements(claim.getLesserBoundaryCorner(), claim.getGreaterBoundaryCorner(), locality, height, cornerBlockData, accentBlockData, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
//adds a general claim cuboid (represented by min and max) visualization to the current visualization
|
||||||
|
public void addClaimElements(Location min, Location max, Location locality, int height, BlockData cornerBlockData, BlockData accentBlockData, int STEP) {
|
||||||
|
World world = min.getWorld();
|
||||||
|
boolean waterIsTransparent = locality.getBlock().getType() == Material.WATER;
|
||||||
|
|
||||||
|
int smallx = min.getBlockX();
|
||||||
|
int smallz = min.getBlockZ();
|
||||||
|
int bigx = max.getBlockX();
|
||||||
|
int bigz = max.getBlockZ();
|
||||||
|
|
||||||
|
ArrayList<VisualizationElement> newElements = new ArrayList<>();
|
||||||
|
|
||||||
//initialize visualization elements without Y values and real data
|
//initialize visualization elements without Y values and real data
|
||||||
//that will be added later for only the visualization elements within visualization range
|
//that will be added later for only the visualization elements within visualization range
|
||||||
|
|
||||||
|
|
@ -183,8 +188,6 @@ public class Visualization
|
||||||
int maxx = locality.getBlockX() + 75;
|
int maxx = locality.getBlockX() + 75;
|
||||||
int maxz = locality.getBlockZ() + 75;
|
int maxz = locality.getBlockZ() + 75;
|
||||||
|
|
||||||
final int STEP = 10;
|
|
||||||
|
|
||||||
//top line
|
//top line
|
||||||
newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz), cornerBlockData, Material.AIR.createBlockData()));
|
newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz), cornerBlockData, Material.AIR.createBlockData()));
|
||||||
newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, bigz), accentBlockData, Material.AIR.createBlockData()));
|
newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, bigz), accentBlockData, Material.AIR.createBlockData()));
|
||||||
|
|
@ -229,10 +232,11 @@ public class Visualization
|
||||||
this.removeElementsOutOfRange(newElements, minx, minz, maxx, maxz);
|
this.removeElementsOutOfRange(newElements, minx, minz, maxx, maxz);
|
||||||
|
|
||||||
//remove any elements outside the claim
|
//remove any elements outside the claim
|
||||||
|
BoundingBox box = BoundingBox.of(min, max);
|
||||||
for (int i = 0; i < newElements.size(); i++)
|
for (int i = 0; i < newElements.size(); i++)
|
||||||
{
|
{
|
||||||
VisualizationElement element = newElements.get(i);
|
VisualizationElement element = newElements.get(i);
|
||||||
if (!claim.contains(element.location, true, false))
|
if (!containsIncludingIgnoringHeight(box, element.location.toVector()))
|
||||||
{
|
{
|
||||||
newElements.remove(i--);
|
newElements.remove(i--);
|
||||||
}
|
}
|
||||||
|
|
@ -250,6 +254,13 @@ public class Visualization
|
||||||
this.elements.addAll(newElements);
|
this.elements.addAll(newElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean containsIncludingIgnoringHeight(BoundingBox box, Vector vector) {
|
||||||
|
return vector.getBlockX() >= box.getMinX()
|
||||||
|
&& vector.getBlockX() <= box.getMaxX()
|
||||||
|
&& vector.getBlockZ() >= box.getMinZ()
|
||||||
|
&& vector.getBlockZ() <= box.getMaxZ();
|
||||||
|
}
|
||||||
|
|
||||||
//removes any elements which are out of visualization range
|
//removes any elements which are out of visualization range
|
||||||
private void removeElementsOutOfRange(ArrayList<VisualizationElement> elements, int minx, int minz, int maxx, int maxz)
|
private void removeElementsOutOfRange(ArrayList<VisualizationElement> elements, int minx, int minz, int maxx, int maxz)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user