Posted June 27, 20169 yr im using a chat event to render some information on screen for some reason in my IDE(intelj idea) it works perfectly but after i build for some reason when i put it on my minecraft it doesnt work [move]CODE FOR MAIN CLASS[/move] package com.SHsuperCM.ElytraMCMod; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_MC_VERS) public class ElytraMCMod { @Instance public static ElytraMCMod instance; com.SHsuperCM.ElytraMCMod.Rings.RingsChatEventHandler ringsChatHandler = new com.SHsuperCM.ElytraMCMod.Rings.RingsChatEventHandler(); com.SHsuperCM.ElytraMCMod.Rings.RingsUIEventHandler ringsUIHandler = new com.SHsuperCM.ElytraMCMod.Rings.RingsUIEventHandler(); @EventHandler public void preInit(FMLPreInitializationEvent event){ ///-Rings-/// MinecraftForge.EVENT_BUS.register(ringsChatHandler); MinecraftForge.EVENT_BUS.register(ringsUIHandler); } @EventHandler public void init(FMLInitializationEvent event){ } @EventHandler public void postInit(FMLPostInitializationEvent event){ } } [move]CODE FOR CHAT CLASS(ringsChatHandler.class)[/move] package com.SHsuperCM.ElytraMCMod.Rings; import com.SHsuperCM.ElytraMCMod.Common.Delay; import com.SHsuperCM.ElytraMCMod.Reference; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; public class RingsChatEventHandler { public static Delay RaceRingTimeout = new Delay(200); public static Delay UnknownTimeout = new Delay(20); @SubscribeEvent public void getChatEvent(ClientChatReceivedEvent event){ String originalMessage = event.getMessage().getFormattedText(); EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(originalMessage.contains("§9Elytra Racing §r§8|§r§e §r§eObjective: §r§aGet to the end of the course before everyone else!")){ //race starting Reference.ActualCheckPointString = "§l§6Getting race info!"; Reference.RaceStarted = true; RaceRingTimeout.Reset(); return; } if(originalMessage.contains("§9Elytra Racing §r§8|§r§e §r§cFailed to reach next ring!")){ // failed RaceRingTimeout.Reset(); Reference.ActualCheckPointString = "§4§lFailed"; UnknownTimeout.Reset(); return; } if(originalMessage.contains("§r§9Elytra Racing §r§8|§r§e §r§eYou have passed ring ")){ //ring passed RaceRingTimeout.Reset(); //Reference.ActualCheckPointString = "§6§lCheckpoint reached!"; ///-Get Ring Cur/Max ///-- i know i did it horrible but it works.. List<Character> chars = new ArrayList<Character>(); for(int i=1; i<originalMessage.length(); i++){ if(originalMessage.charAt(i) == '('){ // ( chars.add(originalMessage.charAt(i+1)); /// ( i if(Character.isDigit(originalMessage.charAt(i+2))){ // ( i d chars.add(originalMessage.charAt(i+2)); /// ( i i if(originalMessage.charAt(i+3) == '/'){ // ( i i / chars.add(originalMessage.charAt(i+3)); /// ( i i / chars.add(originalMessage.charAt(i+4)); /// ( i i / i if(Character.isDigit(originalMessage.charAt(i+5))){ // ( i i / i i chars.add(originalMessage.charAt(i+5)); /// ( i i / i i } } }else { // i / chars.add(originalMessage.charAt(i+2)); /// ( i / chars.add(originalMessage.charAt(i+3)); /// ( i / i if(Character.isDigit(originalMessage.charAt(i+4))) { // ( i / i ? chars.add(originalMessage.charAt(i + 4)); /// ( i / i i } } String out = ""; for (int k = 0; k < chars.size(); k++) { out = out + chars.get(k); } Reference.ActualCheckPointString = "§6§l" + out; return; } } } if(originalMessage.contains("§9Elytra Racing §r§8|§r§e §r§aYou have completed the map")){ /// finished the map Reference.ActualCheckPointString = "§a§lFinished!"; UnknownTimeout.Reset(); } } } from there i have the gui handler and everything which in the ide works but again after build not..... i also tested to output stuff to console and to chat but it seems that the chat event is not working at all after build.... any help is much appriciated Doing stuff n' things
June 27, 20169 yr Author i dont know anything about packets.... im not using a server at all so no proxys and no anything... i just want some code to fire when the client gets a chat message and supply that with the full message itself.... Doing stuff n' things
June 27, 20169 yr Author im not using a server! this is a client mod! there are no proxies at all.. Doing stuff n' things
June 27, 20169 yr Author ITS A MOD THAT WORKS ONLY ON A CLIENT AND JOINS A SERVER!@!!!$!@$#@@#$#!@! UGGGGGHHH!@#!!!!@#$@! Doing stuff n' things
June 27, 20169 yr Author OMG there is a server that is spigot not owned by me and its sending a message to the client a message whenever it passes a checkpoint! im rendering the checkpoint on screen! and it does not communicate with me in any way other than chat! no packets! no forge on the server! only a simple client mod that i get angry for no reason! Doing stuff n' things
June 27, 20169 yr http://new4.fjcdn.com/pictures/Calm+your+tits_428fdc_4406892.jpg[/img] I have no clue what is wrong but: 1. Mark your mod client only (Look insice @Mod annotation). 2. "Doesn't work" - you mean event is not called or it doesn't pass some if statement? Please place print inside event, export it and look into MC logs. 1.7.10 is no longer supported by forge, you are on your own.
June 27, 20169 yr instead of doing it via chat messages... I think it's some kind of "game" that could be built out of even just command blocks. All this fellow is trying to do is render the chat-context information as a HUD element rather than as chat messages. That is: the game can be played without the mod he's writing and the "Checkpoint Reached!" is just a chat message sent by whatever operates the game to the player so that player has some sort of feedback. He's just trying to fancy it up some. Admittedly I would still rebuild the system from the bottom up and use packets, but whatever. Also, Ernio, that is a fantastic image. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 27, 20169 yr Author 1. Mark your mod client only (Look insice @Mod annotation). id look more into the mod annotation now.. i think it may actually be the thing that messes it.. The issue is most likely that your encoding is messed up. Use UTF-8 everywhere. Also, this is a horrible way to do it. The server plugin should communicate with your mod directly, instead of doing it via chat messages... again i dont own the server and i have no clue why i need to mess with just saying UTF-8 I think it's some kind of "game" that could be built out of even just command blocks. All this fellow is trying to do is render the chat-context information as a HUD element rather than as chat messages. That is: the game can be played without the mod he's writing and the "Checkpoint Reached!" is just a chat message sent by whatever operates the game to the player so that player has some sort of feedback. He's just trying to fancy it up some. Thank you so much! finnally someone who gets what im doing Doing stuff n' things
June 27, 20169 yr Author Because if you are not using a unicode encoding like UTF-8 everywhere characters like "§" will not survive properly. I am still saying this is a horrible way to do it. If you want to do it the proper way would be to ask the server owner to expose an API. i still dont understand this, do you say the .contains are not passing because im using the § signs? also all im getting is a chat message and all i want is to display its data.. i dont want anything to do with the server's code... its an early stages server not made by me.. Doing stuff n' things
June 27, 20169 yr Author You are using § in your IDE, yes. At some point during the compilation there is an encoding being used that cannot represent §, so it gets lost. That's why you need to use UTF-8 (or another unicode encoding, but UTF-8 is the most popular). well what if i dont at all use color checks? what if before ill just do: for(int j=1; j<originalMessage.length(); j++){ if(originalMessage.charAt(j) != '§'){ chars1.add(originalMessage.charAt(j)); }else{ j++; } } String message = ""; for (int z = 0; z < chars1.size(); z++) { message = message + chars1.get(z); } and use the messages without the § sign? then when i check, ill check for "clean chat"? if(message.contains("Elytra Racing | Objective: Get to the end of the course before everyone else!")){ //race starting i think this actually might work... im testing it now.. thanks for the information about the builder not understanding § Doing stuff n' things
June 27, 20169 yr Author That is a horrible way to fix it. The way to fix it, is to set your encoding properly. Not do this horrible horrible workaround. i do not know even how to start using UTF-8 i never used it.... do i just need to add some \ with some code? i do not know.. please tellme how do i use it to do § signs Doing stuff n' things
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.