use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox 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.SimpleCollisionBox in project Atlas by funkemunky.
the class PlayerSizeHandlerModern method bounds.
@Override
@SneakyThrows
public SimpleCollisionBox bounds(Player player, double x, double y, double z) {
double width = (double) this.width.invoke(player) / 2;
double height = this.height.invoke(player);
return new SimpleCollisionBox().offset(x, y, z).expand(width, 0, width).expandMax(0, height, 0);
}
use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox in project Atlas by funkemunky.
the class PlayerSizeHandlerModern method bounds.
@SneakyThrows
public SimpleCollisionBox bounds(Player player) {
Location l = player.getLocation();
double width = (double) this.width.invoke(player) / 2;
double height = this.height.invoke(player);
return new SimpleCollisionBox().offset(l.getX(), l.getY(), l.getZ()).expand(width, 0, width).expandMax(0, height, 0);
}
use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox in project Atlas by funkemunky.
the class MinecraftReflection method getCollisionBox.
public static CollisionBox getCollisionBox(Block block) {
Validate.isTrue(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_13));
Object vanillaBlock = CraftReflection.getVanillaBlock(block);
Object vanillaWorld = CraftReflection.getVanillaWorld(block.getWorld());
if (ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_8)) {
Object axisAlignedBB = methodBlockCollisionBox.invoke(vanillaBlock, vanillaWorld, block.getX(), block.getY(), block.getZ());
if (axisAlignedBB != null) {
return new SimpleCollisionBox(axisAlignedBB);
} else
return NoCollisionBox.INSTANCE;
} else {
Object blockPos = new BaseBlockPosition(block.getX(), block.getY(), block.getZ()).getAsBlockPosition();
Object blockData = getBlockData(vanillaBlock);
Object axisAlignedBB = ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_9) ? methodBlockCollisionBox.invoke(vanillaBlock, blockData, vanillaWorld, blockPos) : methodBlockCollisionBox.invoke(vanillaBlock, vanillaWorld, blockPos, blockData);
if (axisAlignedBB != null) {
return new SimpleCollisionBox(axisAlignedBB);
} else
return NoCollisionBox.INSTANCE;
}
}
use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox 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;
}
}
Aggregations