use of net.minecraft.world.entity.ai.control.FlyingMoveControl 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 Mob) || !(entity instanceof NPCHolder))
return;
Mob mob = (Mob) handle;
NPC npc = ((NPCHolder) entity).getNPC();
if (!(mob.getMoveControl() instanceof FlyingMoveControl) || npc.data().has("flying-nogravity-float"))
return;
try {
if (enabled) {
boolean old = (boolean) FLYING_MOVECONTROL_FLOAT_GETTER.invoke(mob.getMoveControl());
FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getMoveControl(), true);
npc.data().set("flying-nogravity-float", old);
} else if (npc.data().has("flying-nogravity-float")) {
FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getMoveControl(), npc.data().get("flying-nogravity-float"));
npc.data().remove("flying-nogravity-float");
}
} catch (Throwable t) {
t.printStackTrace();
}
}
use of net.minecraft.world.entity.ai.control.FlyingMoveControl 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 Mob) || !(entity instanceof NPCHolder))
return;
Mob mob = (Mob) handle;
NPC npc = ((NPCHolder) entity).getNPC();
if (!(mob.getMoveControl() instanceof FlyingMoveControl) || npc.data().has("flying-nogravity-float"))
return;
try {
if (enabled) {
boolean old = (boolean) FLYING_MOVECONTROL_FLOAT_GETTER.invoke(mob.getMoveControl());
FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getMoveControl(), true);
npc.data().set("flying-nogravity-float", old);
} else if (npc.data().has("flying-nogravity-float")) {
FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getMoveControl(), npc.data().get("flying-nogravity-float"));
npc.data().remove("flying-nogravity-float");
}
} catch (Throwable t) {
t.printStackTrace();
}
}
Aggregations