Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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.

Posted

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

Posted

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

Posted

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

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! I have been having a problem with Forgematica, Embeddium, Oculus, and create. I wanted to download litematica so I could see which blocks are in my creative mode build, so that I could collect them all in survival. However, litematica is a fabric mod. I found a port called forgematica, which I added (along with it's dependency) to my mods folder. I loaded into a new world, and built a structure. Then, I added a part from the create mod, and the game crashed instantly, with exit code -1. Thanks for any help! Crash Report and mods list: https://pastebin.com/rtzh6LAi
    • To say that losing 40,000 BTC was a devastating blow would be an understatement. It was an emotional and financial crisis that left me feeling hopeless and utterly lost. For weeks, I was trapped in a whirlwind of regret, second-guessing every decision that led me to that point. The fear that I would never be able to recover such a significant sum of cryptocurrency consumed me, and with each passing day, my despair deepened. I had all but given up on ever regaining my wealth. Then I happened to stumble onto Tech Cyber Force Recovery. In the beginning, I was hesitant. It looked too good to be true: could someone get back so much of their lost Bitcoin? After trying several different approaches and programs without success, I was hesitant to put my trust in another recovery agency. However, I changed my mind after reading Tech Cyber Force Recovery's stellar reviews and reputation. Reaching out to their team was a risk I made. They were courteous and professional from the first time I got in touch with them. I felt like I wasn't just another case to be solved by the staff at Tech Cyber Force Recovery; they truly cared about getting me my lost Bitcoin back. They listened carefully to my circumstances and guided me through each stage, giving me succinct and understandable explanations as I went. Their passion gave me new hope, and their openness instantly made me feel better. As the recovery process began, I still had my doubts, but I knew I had placed my trust in the right hands. The Tech Cyber Force Recovery team kept me informed and updated on their progress, ensuring I never felt in the dark. Despite the complexity of my case, they worked tirelessly, and their expertise became evident at every turn. The level of professionalism and attention to detail they demonstrated throughout the process was beyond impressive. And then, after what felt like an eternity of anticipation, the moment I had been waiting for arrived. I received the news that my 40,000 BTC had been successfully recovered. It was hard to believe at first—it felt like a dream. The weight that had been dragging me down for so long was suddenly lifted, and I could breathe again. The financial loss I had feared would define my future was no longer a reality. I can’t fully express the emotions I felt during that moment. It was a mix of relief, joy, and an overwhelming sense of gratitude. I had gone from a place of utter despair to a complete resurgence of wealth, both emotionally and financially. The Tech Cyber Force Recovery team didn’t just restore my Bitcoin—they restored my faith in the possibility of recovery and gave me back something far more valuable: peace of mind. I will urge anyone in this same predicament to.  
    • Have you found a modder for this vehicle project? Because it will be really hard and I want to know that hero who can create all this
    • and what?????????
  • Topics

×
×
  • Create New...

Important Information

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