Java Code Examples for org.bukkit.util.Vector#getMinimum()

The following examples show how to use org.bukkit.util.Vector#getMinimum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FiniteBlockRegion.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
public FiniteBlockRegion(List<Block> blocks) {
  this.blocks = ImmutableList.copyOf(blocks);

  // calculate AABB
  Vector min = new Vector(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
  Vector max = new Vector(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
  Vector half = new Vector(0.5, 0.5, 0.5);

  ImmutableSet.Builder<MaterialData> materialsBuilder = ImmutableSet.builder();

  for (Block block : this.blocks) {
    Vector center = BlockVectors.center(block).toVector();
    min = Vector.getMinimum(min, center.clone().subtract(half));
    max = Vector.getMaximum(max, center.add(half)); // mutates, but disposed

    materialsBuilder.add(block.getState().getMaterialData());
  }

  this.bounds = new Bounds(min, max);
  this.materials = materialsBuilder.build();
}
 
Example 2
Source File: Bounds.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Bounds intersection(Bounds a, Bounds b) {
  if (a.contains(b)) {
    return b;
  } else if (b.contains(a)) {
    return a;
  } else {
    return new Bounds(Vector.getMaximum(a.min, b.min), Vector.getMinimum(a.max, b.max));
  }
}
 
Example 3
Source File: Bounds.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Bounds union(Bounds a, Bounds b) {
  if (a.contains(b)) {
    return a;
  } else if (b.contains(a)) {
    return b;
  } else {
    return new Bounds(Vector.getMinimum(a.min, b.min), Vector.getMaximum(a.max, b.max));
  }
}
 
Example 4
Source File: CuboidRegion.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
public CuboidRegion(Vector pos1, Vector pos2) {
  this.bounds = new Bounds(Vector.getMinimum(pos1, pos2), Vector.getMaximum(pos1, pos2));
}
 
Example 5
Source File: CuboidRegion.java    From CardinalPGM with MIT License 4 votes vote down vote up
public CuboidRegion(String name, Vector min, Vector max) {
    super(name);
    this.min = Vector.getMinimum(min, max);
    this.max = Vector.getMaximum(min, max);

}