use of org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock 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;
}
}
use of org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock in project Atlas by funkemunky.
the class BlockBox1_17_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
final World world = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
IBlockData iblockData = ((CraftBlock) block).getNMS();
Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
List<AxisAlignedBB> boxes = shape.toList();
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 org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock in project Atlas by funkemunky.
the class BlockBox1_16_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(Block block) {
final net.minecraft.server.v1_16_R1.World world = ((org.bukkit.craftbukkit.v1_16_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
net.minecraft.server.v1_16_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
net.minecraft.server.v1_16_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 org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock in project RoyalGrenadier by BotulToxin.
the class ParsedBlockImpl method test.
@Override
public boolean test(Block block) {
CraftBlock b = (CraftBlock) block;
BlockState state = b.getNMS();
if (!state.is(this.state.getBlock()))
return false;
if (!testProperties(state))
return false;
if (tags == null || tags.isEmpty())
return true;
return compareTags(b.getHandle().getBlockEntity(b.getPosition()));
}
use of org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock in project LoliServer by Loli-Server.
the class BlockEventDispatcher method onBreakBlockEvent.
// For BlockBreakEvent
@SubscribeEvent(receiveCanceled = true)
public void onBreakBlockEvent(BlockEvent.BreakEvent event) {
if (!event.getWorld().isClientSide()) {
CraftBlock craftBlock = CraftBlock.at(event.getWorld(), event.getPos());
BlockBreakEvent breakEvent = new BlockBreakEvent(craftBlock, ((ServerPlayerEntity) event.getPlayer()).getBukkitEntity());
breakEvent.setCancelled(event.isCanceled());
breakEvent.setExpToDrop(event.getExpToDrop());
Bukkit.getPluginManager().callEvent(breakEvent);
event.setCanceled(breakEvent.isCancelled());
event.setExpToDrop(breakEvent.getExpToDrop());
isDropItems = breakEvent.isDropItems();
}
}
Aggregations