Search in sources :

Example 16 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class LevelheadChatRenderer method chat.

@InvokeEvent
public void chat(ServerChatEvent event) {
    if (!levelhead.getDisplayManager().getMasterConfig().isEnabled())
        return;
    LevelheadDisplay chat = Levelhead.getInstance().getDisplayManager().getChat();
    if (chat == null || !levelhead.getLevelheadPurchaseStates().isChat() || !chat.getConfig().isEnabled())
        return;
    List<IChatComponent> siblings = event.getChat().getSiblings();
    if (siblings.size() == 0)
        return;
    IChatComponent chatComponent = siblings.get(0);
    if (chatComponent instanceof ChatComponentText) {
        ChatStyle style = chatComponent.getChatStyle();
        ClickEvent clickEvent = style.getChatClickEvent();
        if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.RUN_COMMAND) {
            String value = clickEvent.getValue();
            HoverEvent hoverEvent = style.getChatHoverEvent();
            if (hoverEvent != null && hoverEvent.getAction() == HoverEvent.Action.SHOW_TEXT) {
                String[] split = value.split(" ");
                if (split.length == 2) {
                    String uuid = split[1];
                    UUID key = UUID.fromString(uuid);
                    String tag = chat.getTrueValueCache().get(key);
                    if (tag != null) {
                        event.setChat(modifyChat(event.getChat(), tag, chat.getConfig()));
                    } else if (!(chat.getCache().get(key) instanceof NullLevelheadTag)) {
                        levelhead.fetch(key, chat, false);
                    }
                }
            }
        }
    }
}
Also used : HoverEvent(net.minecraft.event.HoverEvent) ChatStyle(net.minecraft.util.ChatStyle) ClickEvent(net.minecraft.event.ClickEvent) IChatComponent(net.minecraft.util.IChatComponent) UUID(java.util.UUID) ChatComponentText(net.minecraft.util.ChatComponentText) LevelheadDisplay(cc.hyperium.mods.levelhead.display.LevelheadDisplay) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 17 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class ToggleChatEvents method onChatReceive.

// We use the high priority to grab things first
@InvokeEvent(priority = Priority.HIGH)
public void onChatReceive(ServerChatEvent event) {
    // Strip the message of any colors for improved detectability
    String unformattedText = ChatColor.stripColor(event.getChat().getUnformattedText());
    // The formatted message for a few of the custom toggles
    String formattedText = event.getChat().getFormattedText();
    try {
        // Loop through all the toggles
        for (ToggleBase type : mod.getToggleHandler().getToggles().values()) {
            // The chat its looking for shouldn't be toggled, move to next one!
            if (type.isEnabled())
                continue;
            // the whole toggle system crashing down in flames.
            try {
                // The text we want to input into the shouldToggle method.
                String input = type.useFormattedMessage() ? formattedText : unformattedText;
                // don't send the message to the player & stop looping
                if (type.shouldToggle(input)) {
                    if (type instanceof TypeMessageSeparator) {
                        // Attempt to keep the formatting
                        ChatStyle style = event.getChat().getChatStyle();
                        String edited = ((TypeMessageSeparator) type).editMessage(formattedText);
                        // Don't bother sending the message if its empty
                        if (!input.equals(edited) && edited.isEmpty()) {
                            event.setCancelled(true);
                        } else {
                            event.setChat(new ChatComponentText(edited).setChatStyle(style));
                        }
                    } else {
                        event.setCancelled(true);
                    }
                    break;
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) TypeMessageSeparator(cc.hyperium.mods.togglechat.toggles.defaults.TypeMessageSeparator) ChatComponentText(net.minecraft.util.ChatComponentText) ToggleBase(cc.hyperium.mods.togglechat.toggles.ToggleBase) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 18 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class GeneralStatisticsTracking method onChat.

@InvokeEvent
public void onChat(ChatEvent event) {
    // Check how much the time has changed since the last use.
    checkTimes();
    String line = event.getChat().getUnformattedText();
    if (line.startsWith("+") && line.contains("coins")) {
        int coins = Integer.parseInt(line.split("\\+")[1].split(" coins")[0]);
        // Increment coin counters.
        EventBus.INSTANCE.post(new HypixelGetCoinsEvent(coins));
        lifetimeCoins += coins;
        monthlyCoins += coins;
        dailyCoins += coins;
    }
}
Also used : HypixelGetCoinsEvent(cc.hyperium.event.network.server.hypixel.HypixelGetCoinsEvent) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 19 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class ReachDisplay method attacc.

@InvokeEvent
public void attacc(PlayerAttackEntityEvent entityEvent) {
    if (!Settings.SHOW_HIT_DISTANCES)
        return;
    if (!(entityEvent.getEntity() instanceof EntityLivingBase))
        return;
    if (((EntityLivingBase) entityEvent.getEntity()).hurtTime > 0)
        return;
    if (locked)
        return;
    locked = true;
    EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
    double d0 = 6;
    Vec3 vec3 = entity.getPositionEyes(0.0F);
    Vec3 vec31 = entity.getLook(0.0F);
    Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
    Entity entity1 = entityEvent.getEntity();
    float f1 = .1F;
    AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1);
    MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
    if (movingobjectposition == null)
        return;
    Vec3 vec33 = movingobjectposition.hitVec;
    hits.add(new Hit(vec33, dis));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Vec3(net.minecraft.util.Vec3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 20 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class ReachDisplay method renderWorld.

@InvokeEvent
public void renderWorld(RenderEntitiesEvent event) {
    hits.removeIf(hit -> System.currentTimeMillis() - hit.start > 3000L);
    for (Hit hit : hits) {
        String string = Double.toString(hit.distance);
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        FontRenderer fontrenderer = renderManager.getFontRenderer();
        float f = 1.6F;
        float f1 = 0.016666668F * f;
        GlStateManager.pushMatrix();
        EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
        float partialTicks = event.getPartialTicks();
        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
        GlStateManager.translate(hit.pos.xCoord - d0, hit.pos.yCoord - d1, hit.pos.zCoord - d2);
        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        // Nametag x rotations should flip in front-facing 3rd person
        int xMultiplier = 1;
        if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().gameSettings != null && Minecraft.getMinecraft().gameSettings.thirdPersonView == 2) {
            xMultiplier = -1;
        }
        GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(-f1, -f1, f1);
        GlStateManager.disableLighting();
        GlStateManager.depthMask(false);
        GlStateManager.disableDepth();
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int i = 0;
        int j = fontrenderer.getStringWidth(string) / 2;
        GlStateManager.disableTexture2D();
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        tessellator.draw();
        GlStateManager.enableTexture2D();
        fontrenderer.drawString(string, -j, 0, Settings.REACH_COLOR_TYPE.equalsIgnoreCase("RGB") ? new Color(Settings.REACH_RED, Settings.REACH_GREEN, Settings.REACH_BLUE).getRGB() : Hyperium.INSTANCE.getModIntegration().getLevelhead().getRGBColor(), true);
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
        GlStateManager.enableDepth();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.popMatrix();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) Color(java.awt.Color) FontRenderer(net.minecraft.client.gui.FontRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) RenderManager(net.minecraft.client.renderer.entity.RenderManager) WorldRenderer(net.minecraft.client.renderer.WorldRenderer) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

InvokeEvent (cc.hyperium.event.InvokeEvent)44 HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)7 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)6 UUID (java.util.UUID)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 ScaledResolution (net.minecraft.client.gui.ScaledResolution)4 RenderManager (net.minecraft.client.renderer.entity.RenderManager)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 IMixinModelBiped (cc.hyperium.mixinsimp.client.model.IMixinModelBiped)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 EventBus (cc.hyperium.event.EventBus)2 AutoGG (cc.hyperium.mods.autogg.AutoGG)2 ChatColor (cc.hyperium.utils.ChatColor)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2 Matcher (java.util.regex.Matcher)2 Minecraft (net.minecraft.client.Minecraft)2