Jump to content

Cinque

Members
  • Posts

    12
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Cinque's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. EDIT: Solved it myself! I'm trying to replace a string when a client receives a chat message, however I can't seem to get it working. I tried using the getFormattedText() method which returns a string, however that breaks clickable messages for example. How would I do this?
  2. I got it to work, and only had to use reflection once (the field was an ArrayList so I could just 'cache it'). Thanks a lot!
  3. I'll try, will report back when it's done.
  4. I've cancelled the RenderGameOverlayEvent.Chat and copied the drawChat method into it, however I'm running into a new issue now. This is the code I currently have: @SubscribeEvent public void onChatRender(RenderGameOverlayEvent.Chat e) { e.setCanceled(true); GuiNewChat gui = mc.ingameGUI.getChatGUI(); if (mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) { int j = gui.func_146232_i(); boolean flag = false; int k = 0; int l = gui.field_146253_i.size(); float f = mc.gameSettings.chatOpacity * 0.9F + 0.1F; if (l > 0) { if (gui.getChatOpen()) { flag = true; } float f1 = gui.func_146244_h(); int i1 = MathHelper.ceiling_float_int((float) gui.func_146228_f() / f1); GL11.glPushMatrix(); GL11.glTranslatef(2.0F, 20.0F, 0.0F); GL11.glScalef(f1, f1, 1.0F); int j1; int k1; int i2; for (j1 = 0; j1 + gui.field_146250_j < gui.field_146253_i.size() && j1 < j; ++j1) { ChatLine chatline = (ChatLine) gui.field_146253_i.get(j1 + gui.field_146250_j); if (chatline != null) { k1 = mc.ingameGUI.getUpdateCounter() - chatline.getUpdatedCounter(); if (k1 < 200 || flag) { double d0 = (double) k1 / 200.0D; d0 = 1.0D - d0; d0 *= 10.0D; if (d0 < 0.0D) { d0 = 0.0D; } if (d0 > 1.0D) { d0 = 1.0D; } d0 *= d0; i2 = (int) (255.0D * d0); if (flag) { i2 = 255; } i2 = (int) ((float) i2 * f); ++k; if (i2 > 3) { byte b0 = 0; int j2 = -j1 * 9; GL11.glEnable(GL11.GL_BLEND); String s = chatline.func_151461_a().getFormattedText(); mc.fontRenderer.drawStringWithShadow(s, b0, j2 - 8, 16777215 + (i2 << 24)); GL11.glDisable(GL11.GL_ALPHA_TEST); } } } } if (flag) { j1 = mc.fontRenderer.FONT_HEIGHT; GL11.glTranslatef(-3.0F, 0.0F, 0.0F); int k2 = l * j1 + l; k1 = k * j1 + k; int l2 = gui.field_146250_j * k1 / l; int l1 = k1 * k1 / k2; if (k2 != k1) { i2 = l2 > 0 ? 170 : 96; int i3 = gui.field_146251_k ? 13382451 : 3355562; Gui.drawRect(0, -l2, 2, -l2 - l1, i3 + (i2 << 24)); Gui.drawRect(2, -l2, 1, -l2 - l1, 13421772 + (i2 << 24)); } } GL11.glPopMatrix(); } } } Some fields are not visible. I found a getter method for some of them, however some fields are not visible and don't have a getter either (for example 'field_146253_i').
  5. Oh you're right, didn't realise that. I don't necessarily have to replace the actual chat screen so I don't have to worry about that. I'll see how the chat is drawn in GuiNewChat and try it myself.
  6. I thought of that, however I'm not really sure how I would render the chat myself. For example, I could draw the chat using the drawString method in FontRenderer, but what if the chat message contained a website, how would I make that clickable?
  7. I'm trying to create a mod that removes the chat background (when you send a chat message, there is a transparent gray box behind it). I managed to do this using MCP, however I'd like to make a forge version of it now. When making a normal mod using MCP it's very easy to do, all I did was remove the 'drawRect' line in GuiNewChat, however I'm unsure how to do this in Forge. I noticed that GuiIngame has a field called 'persistantChatGUI', which is an instance of GuiNewChat. My current idea is to create a new class extending GuiNewChat, where the drawRect line is removed, then replace the persistantChatGUI field in GuiIngame using reflection. Is this the only way, or is there an easier solution? Thanks in advance.
  8. Ok, so I want to make a mod where you can enable/disable glass visibility. My idea was to either replace the texture of glass, or change the opacity if possible. I can't really seem to figure out how though. I tried replacing the BlockGlass instance in the Blocks class with a custom class that extends BlockGlass, but it's a final field so I can't modify it. Does anyone know how to do this?
  9. Thanks, I'll start off with just cancelling the MouseEvent and check if that prevents me from hitting entities in multiplayer. EDIT: I just did a quick test with pigs, using this code I can't hit pigs but can hit other entities (which is what I want): @SubscribeEvent public void onMouse(MouseEvent e) { if (mc.objectMouseOver.entityHit instanceof EntityPig) { e.setCanceled(true); } } I'll try to implement this into my friends system now and will post here if it worked or not. Thanks for the help btw EDIT2: This code works, I can't hit people on my friends list on Thanks a lot for you help, probably wouldn't have figured it out myself!
  10. I don't really have any code yet, I tried to just cancel the event in general like this: @SubscribeEvent public void onAttackEntity(AttackEntityEvent e) { e.setCanceled(true); } Using this code, I CAN'T damage entities in singeplayer, but in multiplayer it doesn't work (keep in mind this is a client mod and not a server mod).
  11. Hi, I'm currently working on a PvP mod, and I would like to add a 'friends' feature, where you can add a player as friend so you won't be able to hit them. I can't seem to figure out how to detect if you hit a player though, all I found was LivingHurtEvent, but that doesn't work when using it in multiplayer. I assume I need to listen for a damage packet or something like that, then check the username and cancel it if the player is added to your friendslist, but I can't find much about packets either. Can anyone help me with this? EDIT: After checking the source of Damage Indicators I found out that I could just listen for the AttackEntityEvent instead. I can detect when I try to hit a friend and display a message that I can't hurt him/her, but I can't figure out how to cancel it (e.setCanceled(true) doesn't seem to work for me). SOLVED: I used the MouseEvent then checked if the entity was on my friends list with 'Minecraft.getMinecraft().objectMouseOver.entityHit'. Cancelling this prevented my from hitting people on my friends list.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.