Search in sources :

Example 11 with InvokeEvent

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

the class MinigameListener method onTick.

@InvokeEvent
public void onTick(TickEvent event) {
    if (Minecraft.getMinecraft().theWorld != null && Hyperium.INSTANCE.getHandlers().getHypixelDetector().isHypixel() && Minecraft.getMinecraft().theWorld.getScoreboard() != null) {
        if (cooldown <= 0) {
            cooldown = 3 * 20;
            String minigameName = getScoreboardTitle();
            Arrays.stream(Minigame.values()).filter(m -> minigameName.equalsIgnoreCase(m.scoreName) && !minigameName.equalsIgnoreCase(currentMinigameName)).forEach(m -> {
                currentMinigameName = minigameName;
                EventBus.INSTANCE.post(new JoinMinigameEvent(m));
            });
        } else {
            cooldown--;
        }
    }
}
Also used : InvokeEvent(cc.hyperium.event.InvokeEvent) Arrays(java.util.Arrays) JoinMinigameEvent(cc.hyperium.event.network.server.hypixel.JoinMinigameEvent) Minecraft(net.minecraft.client.Minecraft) EventBus(cc.hyperium.event.EventBus) ChatColor(cc.hyperium.utils.ChatColor) TickEvent(cc.hyperium.event.client.TickEvent) Hyperium(cc.hyperium.Hyperium) JoinMinigameEvent(cc.hyperium.event.network.server.hypixel.JoinMinigameEvent) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 12 with InvokeEvent

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

the class MemoryHelper method tickEvent.

@InvokeEvent
public void tickEvent(TickEvent event) {
    if (tickCounter % 20 * 60 == 0) {
        Minecraft.memoryReserve = new byte[0];
        try {
            Field resourceCache = LaunchClassLoader.class.getDeclaredField("resourceCache");
            resourceCache.setAccessible(true);
            ((Map) resourceCache.get(Launch.classLoader)).clear();
            Field packageManifests = LaunchClassLoader.class.getDeclaredField("packageManifests");
            packageManifests.setAccessible(true);
            ((Map) packageManifests.get(Launch.classLoader)).clear();
        } catch (IllegalAccessException | NoSuchFieldException e) {
            e.printStackTrace();
        }
    }
    tickCounter++;
}
Also used : Field(java.lang.reflect.Field) Map(java.util.Map) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 13 with InvokeEvent

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

the class MemoryHelper method worldEvent.

@InvokeEvent
public void worldEvent(WorldUnloadEvent event) {
    try {
        TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
        Map<ResourceLocation, ITextureObject> mapTextureObjects = ((IMixinTextureManager) textureManager).getMapTextureObjects();
        List<ResourceLocation> removes = new ArrayList<>();
        mapTextureObjects.forEach((key, iTextureObject) -> {
            if (iTextureObject instanceof ThreadDownloadImageData) {
                IImageBuffer imageBuffer = ((IMixinThreadDownloadImageData) iTextureObject).getImageBuffer();
                if (imageBuffer == null)
                    return;
                Class<? extends IImageBuffer> aClass = imageBuffer.getClass();
                // Optifine
                if (aClass.getName().equalsIgnoreCase("CapeImageBuffer")) {
                    removes.add(key);
                }
            }
        });
        removes.forEach(this::deleteSkin);
        // locations.forEach(this::deleteSkin);
        int size = locations.size();
        locations.clear();
        int del = 0;
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        try {
            Method getSkinMap = renderManager.getClass().getMethod("getSkinMap");
            Object invoke = getSkinMap.invoke(renderManager);
            Map<String, RenderPlayer> skinMap = (Map<String, RenderPlayer>) invoke;
            for (RenderPlayer value : skinMap.values()) {
                ModelPlayer mainModel = value.getMainModel();
                Class<?> superClass = mainModel.getClass().getSuperclass();
                for (Field field : superClass.getDeclaredFields()) {
                    field.setAccessible(true);
                    try {
                        Object o = field.get(mainModel);
                        if (o != null) {
                            try {
                                Field entityIn = o.getClass().getSuperclass().getDeclaredField("entityIn");
                                entityIn.setAccessible(true);
                                Object o1 = entityIn.get(o);
                                if (o1 != null) {
                                    entityIn.set(o, null);
                                    del++;
                                }
                            } catch (IllegalAccessException | NoSuchFieldException ignored) {
                            }
                            try {
                                Field clientPlayer = o.getClass().getSuperclass().getDeclaredField("clientPlayer");
                                clientPlayer.setAccessible(true);
                                Object o1 = clientPlayer.get(o);
                                if (o1 != null) {
                                    clientPlayer.set(o, null);
                                    del++;
                                }
                            } catch (IllegalAccessException | NoSuchFieldException ignored) {
                            }
                        }
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
        Hyperium.LOGGER.info("Deleted " + (removes.size() + size + del) + " cosmetic items / skins");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : IMixinThreadDownloadImageData(cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData) ArrayList(java.util.ArrayList) IMixinThreadDownloadImageData(cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData) Field(java.lang.reflect.Field) ResourceLocation(net.minecraft.util.ResourceLocation) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) IMixinTextureManager(cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager) RenderManager(net.minecraft.client.renderer.entity.RenderManager) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TextureManager(net.minecraft.client.renderer.texture.TextureManager) IMixinTextureManager(cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager) ModelPlayer(net.minecraft.client.model.ModelPlayer) IImageBuffer(net.minecraft.client.renderer.IImageBuffer) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) Map(java.util.Map) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 14 with InvokeEvent

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

the class UpdateChecker method serverJoinEvent.

@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
    // If they were already asked, don't even make the new thread.
    if (asked)
        return;
    UpdateUtils updateUtils = new UpdateUtils();
    Multithreading.runAsync(() -> {
        boolean latest = updateUtils.isAbsoluteLatest();
        boolean beta = updateUtils.isBeta();
        int version = Metadata.getVersionID();
        Hyperium.LOGGER.info("version is: " + version);
        // dont alert beta users
        if (beta)
            return;
        // If they're on the latest version, I don't want to mess with them.
        if (latest)
            return;
        Hyperium.INSTANCE.getNotification().display("You have an update pending.", "Click here to be sent to the installer.", 10f, null, () -> {
            try {
                Desktop.getDesktop().browse(new URI("https://hyperium.cc/downloads"));
            } catch (IOException | URISyntaxException e) {
                IChatComponent urlComponent = new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.GRAY + "Click to be sent to update Hyperium");
                urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://hyperium.cc/downloads"));
                Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage(urlComponent);
            }
        }, new Color(200, 150, 50));
        asked = true;
    });
}
Also used : UpdateUtils(cc.hyperium.utils.UpdateUtils) ClickEvent(net.minecraft.event.ClickEvent) ChatColor(cc.hyperium.utils.ChatColor) IChatComponent(net.minecraft.util.IChatComponent) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ChatComponentText(net.minecraft.util.ChatComponentText) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 15 with InvokeEvent

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

the class AboveHeadRenderer method render.

@InvokeEvent
public void render(RenderPlayerEvent event) {
    if (levelhead == null || levelhead.getDisplayManager() == null || levelhead.getDisplayManager().getMasterConfig() == null || !levelhead.getDisplayManager().getMasterConfig().isEnabled()) {
        return;
    }
    EntityPlayer player = event.getEntity();
    int o = 0;
    for (AboveHeadDisplay display : levelhead.getDisplayManager().getAboveHead()) {
        int index = display.getIndex();
        int extraHead = levelhead.getLevelheadPurchaseStates().getExtraHead();
        if (index > extraHead || !display.getConfig().isEnabled())
            continue;
        LevelheadTag levelheadTag = display.getCache().get(player.getUniqueID());
        if (display.loadOrRender(player) && levelheadTag != null && !(levelheadTag instanceof NullLevelheadTag)) {
            if ((event.getEntity().getUniqueID().equals(Levelhead.getInstance().userUuid) && !display.getConfig().isShowSelf() || !Hyperium.INSTANCE.getHandlers().getHypixelDetector().isHypixel())) {
                continue;
            }
            if (player.getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer) < 64 * 64) {
                double offset = 0.3;
                Scoreboard scoreboard = player.getWorldScoreboard();
                ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(2);
                if (objective != null && event.getEntity().getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer) < 10 * 10) {
                    offset *= 2;
                }
                if (player.getUniqueID().equals(levelhead.userUuid) && !Settings.SHOW_OWN_NAME)
                    offset -= .3;
                if (Hyperium.INSTANCE.getCosmetics().getDeadmau5Cosmetic().isPurchasedBy(event.getEntity().getUniqueID())) {
                    HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());
                    if (packageIfReady != null) {
                        AbstractHyperiumPurchase purchase = packageIfReady.getPurchase(EnumPurchaseType.DEADMAU5_COSMETIC);
                        if (purchase != null) {
                            if (event.getEntity().getUniqueID() != Minecraft.getMinecraft().thePlayer.getUniqueID()) {
                                if (((EarsCosmetic) purchase).isEnabled()) {
                                    offset += .3;
                                }
                            } else if (Settings.EARS_STATE.equalsIgnoreCase("on")) {
                                offset += .2;
                            }
                        }
                    }
                }
                offset += levelhead.getDisplayManager().getMasterConfig().getOffset();
                renderName(event, levelheadTag, player, event.getX(), event.getY() + offset + o * .3D, event.getZ());
            }
        }
        o++;
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) AbstractHyperiumPurchase(cc.hyperium.purchases.AbstractHyperiumPurchase) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) Scoreboard(net.minecraft.scoreboard.Scoreboard) AbstractHyperiumPurchase(cc.hyperium.purchases.AbstractHyperiumPurchase) EarsCosmetic(cc.hyperium.purchases.packages.EarsCosmetic) EntityPlayer(net.minecraft.entity.player.EntityPlayer) AboveHeadDisplay(cc.hyperium.mods.levelhead.display.AboveHeadDisplay) 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