Search in sources :

Example 1 with ControllerMoveFlying

use of net.minecraft.server.v1_16_R3.ControllerMoveFlying in project Citizens2 by CitizensDev.

the class NMSImpl method setNoGravity.

@Override
public void setNoGravity(org.bukkit.entity.Entity entity, boolean enabled) {
    Entity handle = getHandle(entity);
    handle.setNoGravity(enabled);
    if (!(handle instanceof EntityInsentient) || !(entity instanceof NPCHolder))
        return;
    EntityInsentient mob = (EntityInsentient) handle;
    NPC npc = ((NPCHolder) entity).getNPC();
    if (!(mob.getControllerMove() instanceof ControllerMoveFlying) || npc.data().has("flying-nogravity-float"))
        return;
    try {
        if (enabled) {
            boolean old = (boolean) FLYING_MOVECONTROL_FLOAT_GETTER.invoke(mob.getControllerMove());
            FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), true);
            npc.data().set("flying-nogravity-float", old);
        } else if (npc.data().has("flying-nogravity-float")) {
            FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), npc.data().get("flying-nogravity-float"));
            npc.data().remove("flying-nogravity-float");
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) ControllerMoveFlying(net.minecraft.server.v1_16_R3.ControllerMoveFlying)

Example 2 with ControllerMoveFlying

use of net.minecraft.server.v1_16_R3.ControllerMoveFlying in project Citizens2 by CitizensDev.

the class NMSImpl method setNoGravity.

@Override
public void setNoGravity(org.bukkit.entity.Entity entity, boolean enabled) {
    Entity handle = getHandle(entity);
    handle.setNoGravity(enabled);
    if (!(handle instanceof EntityInsentient) || !(entity instanceof NPCHolder))
        return;
    EntityInsentient mob = (EntityInsentient) handle;
    NPC npc = ((NPCHolder) entity).getNPC();
    if (!(mob.getControllerMove() instanceof ControllerMoveFlying) || npc.data().has("flying-nogravity-float"))
        return;
    try {
        if (enabled) {
            boolean old = (boolean) FLYING_MOVECONTROL_FLOAT_GETTER.invoke(mob.getControllerMove());
            FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), true);
            npc.data().set("flying-nogravity-float", old);
        } else if (npc.data().has("flying-nogravity-float")) {
            FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), npc.data().get("flying-nogravity-float"));
            npc.data().remove("flying-nogravity-float");
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : EntityHumanNPC(net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC) NPC(net.citizensnpcs.api.npc.NPC) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_15_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityInsentient(net.minecraft.server.v1_15_R1.EntityInsentient) ControllerMoveFlying(net.minecraft.server.v1_15_R1.ControllerMoveFlying)

Aggregations

NPC (net.citizensnpcs.api.npc.NPC)2 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)2 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)2 LivingEntity (org.bukkit.entity.LivingEntity)2 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)1 ControllerMoveFlying (net.minecraft.server.v1_15_R1.ControllerMoveFlying)1 Entity (net.minecraft.server.v1_15_R1.Entity)1 EntityInsentient (net.minecraft.server.v1_15_R1.EntityInsentient)1 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)1 ControllerMoveFlying (net.minecraft.server.v1_16_R3.ControllerMoveFlying)1 Entity (net.minecraft.server.v1_16_R3.Entity)1 EntityInsentient (net.minecraft.server.v1_16_R3.EntityInsentient)1 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)1 CraftEntity (org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity)1 CraftEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity)1