use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.
the class BlockBox1_8_R3 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(Block block) {
final net.minecraft.server.v1_8_R3.World world = ((org.bukkit.craftbukkit.v1_8_R3.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
final AxisAlignedBB collide = BlockBoxManager.cbox.copy().offset(x, y, z).toAxisAlignedBB();
List<AxisAlignedBB> boxes = new ArrayList<>();
net.minecraft.server.v1_8_R3.Block vblock = CraftMagicNumbers.getBlock(block);
net.minecraft.server.v1_8_R3.BlockPosition blockPos = new net.minecraft.server.v1_8_R3.BlockPosition(x, y, z);
vblock.a(world, blockPos, vblock.getBlockData(), collide, boxes, null);
if (boxes.size() == 0) {
AxisAlignedBB box = vblock.a(world, blockPos, vblock.getBlockData());
return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f));
}
return complexBox;
}
}
use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.
the class BlockBox1_12_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(Block block) {
final net.minecraft.server.v1_12_R1.World world = ((org.bukkit.craftbukkit.v1_12_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
final AxisAlignedBB collide = BlockBoxManager.cbox.copy().offset(x, y, z).toAxisAlignedBB();
List<AxisAlignedBB> boxes = new ArrayList<>();
net.minecraft.server.v1_12_R1.Block vblock = CraftMagicNumbers.getBlock(block);
BlockPosition blockPos = new BlockPosition(x, y, z);
vblock.a(vblock.getBlockData(), world, blockPos, collide, boxes, null, false);
if (boxes.size() == 0) {
return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f));
}
return complexBox;
}
}
use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.
the class BlockBox1_13_R2 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(Block block) {
final net.minecraft.server.v1_13_R2.World world = ((org.bukkit.craftbukkit.v1_13_R2.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
net.minecraft.server.v1_13_R2.IBlockData iblockData = ((CraftBlock) block).getNMS();
net.minecraft.server.v1_13_R2.Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, (IBlockAccess) world, blockPos);
List<AxisAlignedBB> boxes = shape.d();
if (boxes.size() == 0) {
return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
}
return complexBox;
}
}
use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.
the class BlockBox1_15_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
final net.minecraft.server.v1_15_R1.World world = ((org.bukkit.craftbukkit.v1_15_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
net.minecraft.server.v1_15_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
net.minecraft.server.v1_15_R1.Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
List<AxisAlignedBB> boxes = shape.d();
if (boxes.size() == 0) {
return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
}
return complexBox;
}
}
use of cc.funkemunky.api.utils.world.types.ComplexCollisionBox in project Atlas by funkemunky.
the class BlockBox1_16_R2 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
final net.minecraft.server.v1_16_R2.World world = ((org.bukkit.craftbukkit.v1_16_R2.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
net.minecraft.server.v1_16_R2.IBlockData iblockData = ((CraftBlock) block).getNMS();
net.minecraft.server.v1_16_R2.Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
List<AxisAlignedBB> boxes = shape.d();
if (boxes.size() == 0) {
return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
}
return complexBox;
}
}
Aggregations