Search in sources :

Example 41 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.

the class NMSImpl method getVehicle.

@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null) {
        return null;
    }
    Entity e = handle.getVehicle();
    return (e == handle || e == null) ? null : e.getBukkitEntity();
}
Also used : PathEntity(net.minecraft.server.v1_13_R2.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) Entity(net.minecraft.server.v1_13_R2.Entity)

Example 42 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, float yaw, float pitch) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    yaw = Util.clampYaw(yaw);
    handle.yaw = yaw;
    setHeadYaw(entity, yaw);
    handle.pitch = pitch;
}
Also used : PathEntity(net.minecraft.server.v1_13_R2.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) Entity(net.minecraft.server.v1_13_R2.Entity)

Example 43 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.

the class NMSImpl method setShouldJump.

@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    if (handle instanceof EntityInsentient) {
        ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
        controller.a();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
Also used : PathEntity(net.minecraft.server.v1_13_R2.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) Entity(net.minecraft.server.v1_13_R2.Entity) EntityInsentient(net.minecraft.server.v1_13_R2.EntityInsentient) ControllerJump(net.minecraft.server.v1_13_R2.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC)

Example 44 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

private PathPoint a(int var1, int var2, int var3, int var4, double var5, EnumDirection var7) {
    PathPoint var8 = null;
    BlockPosition var9 = new BlockPosition(var1, var2, var3);
    double var10 = a(this.a, var9);
    if (var10 - var5 > 1.125D) {
        return null;
    } else {
        PathType var12 = this.a(this.b, var1, var2, var3);
        float var13 = this.b.a(var12);
        double var14 = this.b.width / 2.0D;
        if (var13 >= 0.0F) {
            var8 = this.a(var1, var2, var3);
            var8.m = var12;
            var8.l = Math.max(var8.l, var13);
        }
        if (var12 == PathType.WALKABLE) {
            return var8;
        } else {
            if (var8 == null && var4 > 0 && var12 != PathType.FENCE && var12 != PathType.TRAPDOOR) {
                var8 = this.a(var1, var2 + 1, var3, var4 - 1, var5, var7);
                if (var8 != null && (var8.m == PathType.OPEN || var8.m == PathType.WALKABLE) && this.b.width < 1.0F) {
                    double var16 = var1 - var7.getAdjacentX() + 0.5D;
                    double var18 = var3 - var7.getAdjacentZ() + 0.5D;
                    AxisAlignedBB var20 = new AxisAlignedBB(var16 - var14, var2 + 0.001D, var18 - var14, var16 + var14, this.b.length + a(this.a, var9.up()) - 0.002D, var18 + var14);
                    if (!this.b.world.getCubes((Entity) null, var20)) {
                        var8 = null;
                    }
                }
            }
            if (var12 == PathType.WATER && !this.e()) {
                if (this.a(this.b, var1, var2 - 1, var3) != PathType.WATER) {
                    return var8;
                }
                while (var2 > 0) {
                    --var2;
                    var12 = this.a(this.b, var1, var2, var3);
                    if (var12 != PathType.WATER) {
                        return var8;
                    }
                    var8 = this.a(var1, var2, var3);
                    var8.m = var12;
                    var8.l = Math.max(var8.l, this.b.a(var12));
                }
            }
            if (var12 == PathType.OPEN) {
                AxisAlignedBB var21 = new AxisAlignedBB(var1 - var14 + 0.5D, var2 + 0.001D, var3 - var14 + 0.5D, var1 + var14 + 0.5D, var2 + this.b.length, var3 + var14 + 0.5D);
                if (!this.b.world.getCubes((Entity) null, var21)) {
                    return null;
                }
                if (this.b.width >= 1.0F) {
                    PathType var17 = this.a(this.b, var1, var2 - 1, var3);
                    if (var17 == PathType.BLOCKED) {
                        var8 = this.a(var1, var2, var3);
                        var8.m = PathType.WALKABLE;
                        var8.l = Math.max(var8.l, var13);
                        return var8;
                    }
                }
                int var22 = 0;
                while (var2 > 0 && var12 == PathType.OPEN) {
                    --var2;
                    if (var22++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
                        return null;
                    }
                    var12 = this.a(this.b, var1, var2, var3);
                    var13 = this.b.a(var12);
                    if (var12 != PathType.OPEN && var13 >= 0.0F) {
                        var8 = this.a(var1, var2, var3);
                        var8.m = var12;
                        var8.l = Math.max(var8.l, var13);
                        break;
                    }
                    if (var13 < 0.0F) {
                        return null;
                    }
                }
            }
            return var8;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.server.v1_13_R2.AxisAlignedBB) PathPoint(net.minecraft.server.v1_13_R2.PathPoint) PathType(net.minecraft.server.v1_13_R2.PathType) Entity(net.minecraft.server.v1_13_R2.Entity) MutableBlockPosition(net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_13_R2.BlockPosition) PathPoint(net.minecraft.server.v1_13_R2.PathPoint)

Example 45 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
    Entity handle = NMSImpl.getHandle(entity);
    if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
        Location fromLocation = entity.getLocation(FROM_LOCATION);
        double xDiff, yDiff, zDiff;
        xDiff = to.getX() - fromLocation.getX();
        yDiff = to.getY() - fromLocation.getY();
        zDiff = to.getZ() - fromLocation.getZ();
        double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
        double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
        double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
        double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
        if (zDiff < 0.0)
            yaw += Math.abs(180 - yaw) * 2;
        if (handle instanceof EntityEnderDragon) {
            yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
        } else {
            yaw = yaw - 90;
        }
        if (headOnly) {
            setHeadYaw(entity, (float) yaw);
        } else {
            look(entity, (float) yaw, (float) pitch);
        }
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), ((EntityInsentient) handle).O(), ((EntityInsentient) handle).N());
        while (((EntityLiving) handle).aP >= 180F) {
            ((EntityLiving) handle).aP -= 360F;
        }
        while (((EntityLiving) handle).aP < -180F) {
            ((EntityLiving) handle).aP += 360F;
        }
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setTargetLook(to);
    }
}
Also used : PathEntity(net.minecraft.server.v1_12_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_12_R1.Entity) EntityEnderDragon(net.minecraft.server.v1_12_R1.EntityEnderDragon) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)114 Entity (org.hypertrace.entity.data.service.v1.Entity)110 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)102 Test (org.junit.jupiter.api.Test)95 CraftEntity (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity)53 Entity (net.minecraft.world.entity.Entity)42 Location (org.bukkit.Location)41 ArrayList (java.util.ArrayList)39 Entity (com.google.datastore.v1.Entity)33 net.minecraft.world.entity (net.minecraft.world.entity)33 org.bukkit.entity (org.bukkit.entity)32 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Player (org.bukkit.entity.Player)29 ServerPlayer (net.minecraft.server.level.ServerPlayer)28 LivingEntity (net.minecraft.world.entity.LivingEntity)28 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)28 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)27 Event (org.hypertrace.core.datamodel.Event)27 Mob (net.minecraft.world.entity.Mob)25 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)23