mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-21 05:44:17 +00:00
#621: Add Block#getCollisionShape and associated API
This commit is contained in:
parent
83f547f227
commit
7984eb75a4
2 changed files with 40 additions and 0 deletions
|
@ -15,6 +15,7 @@ import org.bukkit.metadata.Metadatable;
|
||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.bukkit.util.RayTraceResult;
|
import org.bukkit.util.RayTraceResult;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.bukkit.util.VoxelShape;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -501,4 +502,13 @@ public interface Block extends Metadatable {
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
BoundingBox getBoundingBox();
|
BoundingBox getBoundingBox();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the collision shape of this block.
|
||||||
|
*
|
||||||
|
* @return a {@link VoxelShape} representing the collision shape of this
|
||||||
|
* block.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
VoxelShape getCollisionShape();
|
||||||
}
|
}
|
||||||
|
|
30
src/main/java/org/bukkit/util/VoxelShape.java
Normal file
30
src/main/java/org/bukkit/util/VoxelShape.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package org.bukkit.util;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A shape made out of voxels.
|
||||||
|
*
|
||||||
|
* For example, used to represent the detailed collision shape of blocks.
|
||||||
|
*/
|
||||||
|
public interface VoxelShape {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this shape into a collection of {@link BoundingBox} equivalent
|
||||||
|
* to the shape: a bounding box intersects with this block shape if it
|
||||||
|
* intersects with any of the shape's bounding boxes.
|
||||||
|
*
|
||||||
|
* @return shape converted to bounding boxes
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Collection<BoundingBox> getBoundingBoxes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given bounding box intersects this block shape.
|
||||||
|
*
|
||||||
|
* @param other bounding box to test
|
||||||
|
* @return true if other overlaps this, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean overlaps(@NotNull BoundingBox other);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue