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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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