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