Search in sources :

Example 1 with BoundingBox

use of com.denizenscript.denizen.nms.util.BoundingBox in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method getBoundingBox.

@Override
public BoundingBox getBoundingBox(Entity entity) {
    AABB boundingBox = ((CraftEntity) entity).getHandle().getBoundingBox();
    Vector position = new Vector(boundingBox.minX, boundingBox.minY, boundingBox.minZ);
    Vector size = new Vector(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
    return new BoundingBox(position, size);
}
Also used : BoundingBox(com.denizenscript.denizen.nms.util.BoundingBox) Vector(org.bukkit.util.Vector) AABB(net.minecraft.world.phys.AABB)

Example 2 with BoundingBox

use of com.denizenscript.denizen.nms.util.BoundingBox in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method getBoundingBox.

@Override
public BoundingBox getBoundingBox(Entity entity) {
    AABB boundingBox = ((CraftEntity) entity).getHandle().getBoundingBox();
    Vector position = new Vector(boundingBox.minX, boundingBox.minY, boundingBox.minZ);
    Vector size = new Vector(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
    return new BoundingBox(position, size);
}
Also used : BoundingBox(com.denizenscript.denizen.nms.util.BoundingBox) Vector(org.bukkit.util.Vector) AABB(net.minecraft.world.phys.AABB)

Example 3 with BoundingBox

use of com.denizenscript.denizen.nms.util.BoundingBox in project Denizen-For-Bukkit by DenizenScript.

the class EntityBoundingBox method getBoundingBox.

private ListTag getBoundingBox() {
    BoundingBox boundingBox = NMSHandler.getEntityHelper().getBoundingBox(entity.getBukkitEntity());
    ListTag list = new ListTag();
    list.addObject(new LocationTag(boundingBox.getLow().toLocation(entity.getWorld())));
    list.addObject(new LocationTag(boundingBox.getHigh().toLocation(entity.getWorld())));
    return list;
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) BoundingBox(com.denizenscript.denizen.nms.util.BoundingBox) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 4 with BoundingBox

use of com.denizenscript.denizen.nms.util.BoundingBox in project Denizen-For-Bukkit by DenizenScript.

the class EntityBoundingBox method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("bounding_box") && mechanism.requireObject(ListTag.class)) {
        if (entity.isCitizensNPC()) {
            // TODO: Allow editing NPC boxes properly?
            return;
        }
        List<LocationTag> locations = mechanism.valueAsType(ListTag.class).filter(LocationTag.class, mechanism.context);
        if (locations.size() == 2) {
            BoundingBox boundingBox = new BoundingBox(locations.get(0).toVector(), locations.get(1).toVector());
            NMSHandler.getEntityHelper().setBoundingBox(entity.getBukkitEntity(), boundingBox);
            modifiedBoxes.add(entity.getUUID());
        } else {
            mechanism.echoError("Must specify exactly 2 LocationTags in the format '<low>|<high>'!");
        }
    }
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) BoundingBox(com.denizenscript.denizen.nms.util.BoundingBox) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 5 with BoundingBox

use of com.denizenscript.denizen.nms.util.BoundingBox in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method getBoundingBox.

@Override
public BoundingBox getBoundingBox(Entity entity) {
    AxisAlignedBB boundingBox = ((CraftEntity) entity).getHandle().getBoundingBox();
    Vector position = new Vector(boundingBox.minX, boundingBox.minY, boundingBox.minZ);
    Vector size = new Vector(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
    return new BoundingBox(position, size);
}
Also used : BoundingBox(com.denizenscript.denizen.nms.util.BoundingBox) Vector(org.bukkit.util.Vector)

Aggregations

BoundingBox (com.denizenscript.denizen.nms.util.BoundingBox)5 Vector (org.bukkit.util.Vector)3 LocationTag (com.denizenscript.denizen.objects.LocationTag)2 ListTag (com.denizenscript.denizencore.objects.core.ListTag)2 AABB (net.minecraft.world.phys.AABB)2