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();
}
}
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)));
}
}
}
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();
}
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)));
}
}
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);
}
}
Aggregations