Search in sources :

Example 76 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class FlipKeybind method onPress.

@Override
public void onPress() {
    if (!Hyperium.INSTANCE.getCosmetics().getFlipCosmetic().isSelfUnlocked()) {
        return;
    }
    if (Settings.isFlipToggle) {
        inverted = !inverted;
        int state = inverted ? Settings.flipType : 0;
        Hyperium.INSTANCE.getHandlers().getFlipHandler().state(UUIDUtil.getClientUUID(), state);
        NettyClient client = NettyClient.getClient();
        if (client != null) {
            client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "flip_update").put("flip_state", state)));
        }
        Hyperium.INSTANCE.getHandlers().getFlipHandler().resetTick();
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) NettyClient(cc.hyperium.netty.NettyClient)

Example 77 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class FlipKeybind method onRelease.

@Override
public void onRelease() {
    if (!Hyperium.INSTANCE.getCosmetics().getFlipCosmetic().isSelfUnlocked()) {
        return;
    }
    if (!Settings.isFlipToggle) {
        inverted = !inverted;
        int state = inverted ? Settings.flipType : 0;
        Hyperium.INSTANCE.getHandlers().getFlipHandler().state(UUIDUtil.getClientUUID(), state);
        NettyClient client = NettyClient.getClient();
        if (client != null) {
            client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "flip_update").put("flip_state", state)));
        }
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) NettyClient(cc.hyperium.netty.NettyClient)

Example 78 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class AnimatedDance method generateFrames.

public void generateFrames(JsonHolder data) {
    frames.clear();
    HashMap<String, Boolean> visibility = new HashMap<>();
    for (JsonElement element : data.optJSONArray("frames")) {
        JsonHolder h = new JsonHolder(element.getAsJsonObject());
        int time = h.optInt("time");
        AnimationFrame frame = new AnimationFrame(frame(time));
        frame.name = h.optInt("time") + "";
        h.getKeys().forEach(s -> {
            visibility.put(s, true);
            if (!s.equalsIgnoreCase("time")) {
                try {
                    Field declaredField1 = frame.getClass().getDeclaredField(s);
                    declaredField1.setAccessible(true);
                    BodyPart bodyPart = (BodyPart) declaredField1.get(frame);
                    JsonHolder holder1 = h.optJSONObject(s);
                    for (String s1 : holder1.getKeys()) {
                        Field declaredField = bodyPart.getClass().getDeclaredField(s1);
                        declaredField.setAccessible(true);
                        if (s1.equalsIgnoreCase("visible")) {
                            boolean visible = holder1.optBoolean("visible");
                            visibility.put(s, visible);
                            declaredField.setBoolean(bodyPart, visible);
                        } else {
                            float f = (float) holder1.optDouble(s1);
                            declaredField.setFloat(bodyPart, f);
                        }
                    }
                    bodyPart.getClass().getDeclaredField("visible").setBoolean(bodyPart, visibility.get(s));
                } catch (IllegalAccessException | NoSuchFieldException e) {
                    e.printStackTrace();
                }
            }
        });
        frames.add(frame);
    }
    loaded = true;
    if (frames.size() == 0)
        duration = 1L;
    else
        duration = frames.get(Math.max(0, frames.size() - 1)).getTime();
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) HashMap(java.util.HashMap) Field(java.lang.reflect.Field) JsonElement(com.google.gson.JsonElement)

Example 79 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class DabKeybind method onPress.

@Override
public void onPress() {
    DabHandler dabHandler = Hyperium.INSTANCE.getHandlers().getDabHandler();
    UUID uuid = (Minecraft.getMinecraft().getSession()).getProfile().getId();
    AbstractAnimationHandler.AnimationState currentState = dabHandler.get(uuid);
    NettyClient client = NettyClient.getClient();
    if (Settings.DAB_TOGGLE && currentState.isAnimating() && !wasPressed()) {
        currentState.setToggled(false);
        dabHandler.stopAnimation(uuid);
        if (client != null) {
            client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "dab_update").put("dabbing", false)));
        }
        return;
    }
    if (!wasPressed()) {
        currentState.setToggled(Settings.DAB_TOGGLE);
        dabHandler.startAnimation(uuid);
    }
    if (client != null) {
        client.write(ServerCrossDataPacket.build(new JsonHolder().put("type", "dab_update").put("dabbing", true)));
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) NettyClient(cc.hyperium.netty.NettyClient) DabHandler(cc.hyperium.handlers.handlers.animation.DabHandler) AbstractAnimationHandler(cc.hyperium.handlers.handlers.animation.AbstractAnimationHandler) UUID(java.util.UUID)

Example 80 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class GuiHyperiumScreenIngameMenu method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    drawDefaultBackground();
    if (PurchaseApi.getInstance() != null && PurchaseApi.getInstance().getSelf() != null) {
        JsonHolder response = PurchaseApi.getInstance().getSelf().getResponse();
        int credits = response.optInt("remaining_credits");
        /* Render player credits count and username */
        fontRendererObj.drawStringWithShadow(Minecraft.getMinecraft().getSession().getUsername(), 3, 5, 0xFFFFFF);
        fontRendererObj.drawStringWithShadow(I18n.format("menu.profile.credits", credits), 3, 15, 0xFFFF00);
    }
    super.drawScreen(mouseX, mouseY, partialTicks);
    GlStateManager.translate(0, height - 50, 0);
    if (System.currentTimeMillis() - lastUpdate > 2000L)
        refreshData();
    baseAngle %= 360;
    ScaledResolution current = ResolutionUtil.current();
    GlStateManager.translate(current.getScaledWidth() >> 1, 5, 0);
    drawCenteredString(fontRendererObj, I18n.format("gui.ingamemenu.playercount"), 0, -5, 0xFFFFFF);
    GlStateManager.translate(0F, 10F, 0F);
    GlStateManager.scale(1, 1, 1);
    GlStateManager.rotate(baseAngle, 1.0F, 0.0F, 0.0F);
    float z = 4F;
    float e = 80;
    float i = 0;
    GlStateManager.translate(0.0F, 0.0F, z);
    if (baseAngle < e)
        i = (e - Math.abs(baseAngle)) / e;
    else if (baseAngle > 360 - e)
        i = (e - (Math.abs((360) - baseAngle))) / e;
    if (i > 0) {
        drawCenteredString(fontRendererObj, I18n.format("gui.ingamemenu.playercount.now", ChatColor.GREEN + formatter.format(data.optInt("online")) + ChatColor.RESET), 0, 0, 0xFFFFFF);
    }
    GlStateManager.translate(0.0F, 0.0F, -z);
    GlStateManager.rotate(90, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(0.0F, 0.0F, z);
    i = (e - Math.abs(270 - baseAngle)) / e;
    if (i > 0) {
        drawCenteredString(fontRendererObj, I18n.format("gui.ingamemenu.playercount.lastday", ChatColor.GREEN + formatter.format(data.optInt("day")) + ChatColor.RESET), 0, 0, 0xFFFFFF);
    }
    GlStateManager.translate(0.0F, 0.0F, -z);
    GlStateManager.rotate(90, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(0.0F, 0.0F, z);
    i = (e - Math.abs(180 - baseAngle)) / e;
    if (i > 0) {
        drawCenteredString(fontRendererObj, I18n.format("gui.ingamemenu.playercount.lastweek", ChatColor.GREEN + formatter.format(data.optInt("week")) + ChatColor.RESET), 0, 0, 0xFFFFFF);
    }
    GlStateManager.translate(0.0F, 0.0F, -z);
    GlStateManager.rotate(90, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(0.0F, 0.0F, z);
    i = (e - Math.abs(90 - baseAngle)) / e;
    if (i > 0) {
        drawCenteredString(fontRendererObj, I18n.format("gui.ingamemenu.playercount.alltime", ChatColor.GREEN + formatter.format(data.optInt("all")) + ChatColor.RESET), 0, 0, 0xFFFFFF);
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder)

Aggregations

JsonHolder (cc.hyperium.utils.JsonHolder)81 DisplayLine (cc.hyperium.handlers.handlers.stats.display.DisplayLine)42 StatsDisplayItem (cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem)42 ArrayList (java.util.ArrayList)34 NettyClient (cc.hyperium.netty.NettyClient)13 DisplayTable (cc.hyperium.handlers.handlers.stats.display.DisplayTable)10 JsonArray (com.google.gson.JsonArray)9 JsonElement (com.google.gson.JsonElement)8 HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)5 JsonObject (com.google.gson.JsonObject)5 URL (java.net.URL)5 UUID (java.util.UUID)5 HashMap (java.util.HashMap)4 InvokeEvent (cc.hyperium.event.InvokeEvent)3 PurchaseLoadEvent (cc.hyperium.event.network.PurchaseLoadEvent)3 AbstractAnimationHandler (cc.hyperium.handlers.handlers.animation.AbstractAnimationHandler)3 DisplayItem (cc.hyperium.mods.chromahud.api.DisplayItem)3 IOException (java.io.IOException)3 ExecutionException (java.util.concurrent.ExecutionException)3 GuiButton (net.minecraft.client.gui.GuiButton)3