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