Commits
Evoluseis authored and md_5 committed f55c8191850
23 23 | import org.bukkit.craftbukkit.CraftFluidCollisionMode; |
24 24 | import org.bukkit.craftbukkit.CraftWorld; |
25 25 | import org.bukkit.craftbukkit.block.data.CraftBlockData; |
26 26 | import org.bukkit.craftbukkit.inventory.CraftItemStack; |
27 27 | import org.bukkit.craftbukkit.util.CraftMagicNumbers; |
28 28 | import org.bukkit.craftbukkit.util.CraftRayTraceResult; |
29 29 | import org.bukkit.inventory.ItemStack; |
30 30 | import org.bukkit.metadata.MetadataValue; |
31 31 | import org.bukkit.plugin.Plugin; |
32 32 | import org.bukkit.util.BlockVector; |
33 + | import org.bukkit.util.BoundingBox; |
33 34 | import org.bukkit.util.RayTraceResult; |
34 35 | import org.bukkit.util.Vector; |
35 36 | |
36 37 | public class CraftBlock implements Block { |
37 38 | private final net.minecraft.server.GeneratorAccess world; |
38 39 | private final BlockPosition position; |
39 40 | |
40 41 | public CraftBlock(GeneratorAccess world, BlockPosition position) { |
41 42 | this.world = world; |
42 43 | this.position = position; |
641 642 | if (collidableBlock) { |
642 643 | nmsHitResult = net.minecraft.server.Block.rayTrace(blockData, world.getMinecraftWorld(), position, startPos, endPos); |
643 644 | } |
644 645 | |
645 646 | if (nmsHitResult == null && collideWithFluid) { |
646 647 | nmsHitResult = VoxelShapes.create(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid.getHeight(), 1.0D).rayTrace(startPos, endPos, position); |
647 648 | } |
648 649 | |
649 650 | return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult); |
650 651 | } |
652 + | |
653 + | |
654 + | public BoundingBox getBoundingBox() { |
655 + | VoxelShape shape = getData0().g(world, position); // PAIL: getShape |
656 + | |
657 + | if (shape.isEmpty()) { |
658 + | return new BoundingBox(); // Return an empty bounding box if the block has no dimension |
659 + | } |
660 + | |
661 + | AxisAlignedBB aabb = shape.a(); // PAIL: getBoundingBox |
662 + | return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ); |
663 + | } |
651 664 | } |