Search in sources :

Example 1 with TPoseHandler

use of cc.hyperium.handlers.handlers.animation.TPoseHandler in project Hyperium by HyperiumClient.

the class TPoseKeybind method onPress.

@Override
public void onPress() {
    TPoseHandler tPoseHandler = Hyperium.INSTANCE.getHandlers().getTPoseHandler();
    UUID uuid = (Minecraft.getMinecraft().getSession()).getProfile().getId();
    AbstractAnimationHandler.AnimationState currentState = tPoseHandler.get(uuid);
    tPoseToggled = !Settings.TPOSE_TOGGLE_MODE || !tPoseToggled;
    NettyClient client = NettyClient.getClient();
    if (Settings.TPOSE_TOGGLE_MODE) {
        currentState.setToggled(tPoseToggled);
        if (tPoseToggled)
            tPoseHandler.startAnimation(uuid);
        else
            tPoseHandler.stopAnimation(uuid);
        if (client != null) {
            client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "tpose_update").put("posing", tPoseToggled)));
        }
        return;
    }
    if (Settings.TPOSE_TOGGLE && currentState.isAnimating() && !wasPressed()) {
        currentState.setToggled(false);
        tPoseHandler.stopAnimation(uuid);
        if (client != null) {
            client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "tpose_update").put("posing", false)));
        }
        return;
    }
    if (!wasPressed()) {
        currentState.setToggled(Settings.TPOSE_TOGGLE);
        tPoseHandler.startAnimation(uuid);
    }
    if (client != null) {
        client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "tpose_update").put("posing", true)));
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) NettyClient(cc.hyperium.netty.NettyClient) AbstractAnimationHandler(cc.hyperium.handlers.handlers.animation.AbstractAnimationHandler) TPoseHandler(cc.hyperium.handlers.handlers.animation.TPoseHandler) UUID(java.util.UUID)

Aggregations

AbstractAnimationHandler (cc.hyperium.handlers.handlers.animation.AbstractAnimationHandler)1 TPoseHandler (cc.hyperium.handlers.handlers.animation.TPoseHandler)1 NettyClient (cc.hyperium.netty.NettyClient)1 JsonHolder (cc.hyperium.utils.JsonHolder)1 UUID (java.util.UUID)1