3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 06:40:07 +01:00

SPIGOT-2151: Add support for getting simple bounding box of a block

Dieser Commit ist enthalten in:
Evoluseis 2018-12-17 19:11:04 -05:00 committet von md_5
Ursprung 4b843638ea
Commit f55c819185

Datei anzeigen

@ -30,6 +30,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.BlockVector;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;
@ -648,4 +649,16 @@ public class CraftBlock implements Block {
return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult);
}
@Override
public BoundingBox getBoundingBox() {
VoxelShape shape = getData0().g(world, position); // PAIL: getShape
if (shape.isEmpty()) {
return new BoundingBox(); // Return an empty bounding box if the block has no dimension
}
AxisAlignedBB aabb = shape.a(); // PAIL: getBoundingBox
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
}
}