Search in sources :

Example 6 with SimpleCollisionBox

use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox in project Kauri by funkemunky.

the class BukkitListener method boxToString.

private static String boxToString(CollisionBox box) {
    if (box instanceof SimpleCollisionBox) {
        SimpleCollisionBox sbox = (SimpleCollisionBox) box;
        return "SimpleCollisionBox[" + vectorToString(sbox.toBoundingBox().getMinimum()) + ", " + vectorToString(sbox.toBoundingBox().getMaximum()) + "]";
    } else {
        List<SimpleCollisionBox> downCasted = new ArrayList<>();
        box.downCast(downCasted);
        return "ComplexBox[" + downCasted.stream().map(sbox -> "SimpleCollisionBox[" + vectorToString(sbox.toBoundingBox().getMinimum()) + ", " + vectorToString(sbox.toBoundingBox().getMaximum()) + "]").collect(Collectors.joining(", ")) + "]";
    }
}
Also used : SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) MinecraftReflection(cc.funkemunky.api.reflections.impl.MinecraftReflection) Action(org.bukkit.event.block.Action) Kauri(dev.brighten.anticheat.Kauri) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) WrappedEnumParticle(cc.funkemunky.api.tinyprotocol.packet.types.enums.WrappedEnumParticle) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) cc.funkemunky.api.utils(cc.funkemunky.api.utils) ObjectData(dev.brighten.anticheat.data.ObjectData) lombok.val(lombok.val) ThreadHandler(dev.brighten.anticheat.processing.thread.ThreadHandler) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) List(java.util.List) BlockStateManager(cc.funkemunky.api.utils.world.state.BlockStateManager) EventPriority(org.bukkit.event.EventPriority) PlayerQuitEvent(org.bukkit.event.player.PlayerQuitEvent) BlockData(cc.funkemunky.api.utils.world.BlockData) Collections(java.util.Collections) ProtocolVersion(cc.funkemunky.api.tinyprotocol.api.ProtocolVersion) CollisionBox(cc.funkemunky.api.utils.world.CollisionBox) ArrayList(java.util.ArrayList)

Example 7 with SimpleCollisionBox

use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox in project Kauri by funkemunky.

the class BlockC method onBlockPlace.

@Packet
public void onBlockPlace(WrappedInBlockPlacePacket event) {
    Location loc = event.getBlockPosition().toBukkitVector().toLocation(event.getPlayer().getWorld());
    Optional<Block> optionalBlock = BlockUtils.getBlockAsync(loc);
    if (!optionalBlock.isPresent())
        return;
    final Block block = optionalBlock.get();
    CollisionBox box = BlockData.getData(block.getType()).getBox(block, data.playerVersion);
    if (!(box instanceof SimpleCollisionBox)) {
        debug("Not SimpleCollisionBox");
        return;
    }
    final SimpleCollisionBox simpleBox = ((SimpleCollisionBox) box);
    if (Math.abs(simpleBox.yMax - simpleBox.yMin) != 1. || Math.abs(simpleBox.xMax - simpleBox.xMin) != 1. || Math.abs(simpleBox.zMax - simpleBox.zMin) != 1.) {
        debug("not full block: x=%.1f y=%.1f z=%.1f", Math.abs(simpleBox.xMax - simpleBox.xMin), Math.abs(simpleBox.yMax - simpleBox.yMin), Math.abs(simpleBox.zMax - simpleBox.zMin));
        return;
    }
    blockPlacements.add(new Tuple<>(block, simpleBox.expand(0.1)));
}
Also used : SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) Block(org.bukkit.block.Block) KLocation(cc.funkemunky.api.utils.KLocation) Location(org.bukkit.Location) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) CollisionBox(cc.funkemunky.api.utils.world.CollisionBox) WrappedInFlyingPacket(cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket) Packet(dev.brighten.anticheat.check.api.Packet) WrappedInBlockPlacePacket(cc.funkemunky.api.tinyprotocol.packet.in.WrappedInBlockPlacePacket)

Example 8 with SimpleCollisionBox

use of cc.funkemunky.api.utils.world.types.SimpleCollisionBox in project Kauri by funkemunky.

the class MiscUtils method getNearbyEntities.

public static List<Entity> getNearbyEntities(Player player, double horz, double vert) {
    final List<Entity> nearbyEntities = new ArrayList<>();
    final SimpleCollisionBox playerBox = new SimpleCollisionBox(player.getLocation(), 0.6, 1.8);
    for (Entity entity : Atlas.getInstance().getTrackedEntities().values()) {
        if (!entity.getWorld().getUID().equals(player.getWorld().getUID()) || player.getEntityId() == entity.getEntityId())
            continue;
        SimpleCollisionBox box = new SimpleCollisionBox(entity.getLocation(), horz * 2, vert / 2).expandMin(0, -(vert / 2), 0);
        if (box.isCollided(playerBox))
            nearbyEntities.add(entity);
    }
    return nearbyEntities;
}
Also used : SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) HumanEntity(org.bukkit.entity.HumanEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity)

Example 9 with SimpleCollisionBox

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;
    }
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) ArrayList(java.util.ArrayList) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 10 with SimpleCollisionBox

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);
}
Also used : SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) SneakyThrows(lombok.SneakyThrows)

Aggregations

SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)39 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)20 ArrayList (java.util.ArrayList)11 KLocation (cc.funkemunky.api.utils.KLocation)8 CollisionBox (cc.funkemunky.api.utils.world.CollisionBox)7 Block (org.bukkit.block.Block)7 Packet (dev.brighten.anticheat.check.api.Packet)6 Location (org.bukkit.Location)6 Vector (org.bukkit.util.Vector)6 WrappedInFlyingPacket (cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket)5 WrappedInUseEntityPacket (cc.funkemunky.api.tinyprotocol.packet.in.WrappedInUseEntityPacket)4 RayCollision (cc.funkemunky.api.utils.world.types.RayCollision)4 AxisAlignedBB (dev.brighten.anticheat.utils.AxisAlignedBB)3 Vec3D (dev.brighten.anticheat.utils.Vec3D)3 lombok.val (lombok.val)3 Material (org.bukkit.Material)3 Entity (org.bukkit.entity.Entity)3 ProtocolVersion (cc.funkemunky.api.tinyprotocol.api.ProtocolVersion)2 WrappedInBlockPlacePacket (cc.funkemunky.api.tinyprotocol.packet.in.WrappedInBlockPlacePacket)2 BlockData (cc.funkemunky.api.utils.world.BlockData)2