Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to replace net.minecraft.util.ChatAllowedCharacters to make it possible (with checks) to enter the § symbol. How can i do this?

  • Author
6 minutes ago, Matryoshika said:

ASM/Core editing is not supported by Forge.
A Moderator will likely lock this thread unless you change to a more viable solution.

Is there any other way?

  • Author
1 hour ago, diesieben07 said:

Use ClientChatEvent to catch the message being sent. Cancel the event and send a custom packet instead, which allows the characters.

Alternatively create a pull request to Forge.

Thanks

 

  • Author

Darn.

"Illegal Charaters in chat" :(

I typed "&3hi"

Which becomes "§3hi"

package mods.giantnuker;

import java.util.List;

import com.google.common.collect.Lists;

import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod(modid = ColorChatMod.MODID, version = ColorChatMod.VERSION)
public class ColorChatMod
{
    public static final String MODID = "colorchat";
    public static final String VERSION = "1.0";
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        MinecraftForge.EVENT_BUS.register(this);
    }
    public static final char sect_sign = '§', sect_replace = '&';
	public static final List<Character> codes = Lists.newArrayList(new Character[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'k', 'l', 'm', 'n', 'o', 'r'});
	@SubscribeEvent
	public void colorChat(ClientChatEvent e) {
		//if (!e.getMessage().contains(String.valueOf(sect_replace))) return;
		String msg = e.getMessage();
		char[] array = msg.toCharArray();
		for (int i = 0; i < array.length; i++) {
			if (array[i] == sect_replace && i < (array.length - 1) && codes.contains(array[i + 1])) {
				array[i] = sect_sign;
			}
		}
		e.setMessage(String.valueOf(array));
	}
}

Is there any way around this without resorting to modding the server?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.