Posted December 30, 20177 yr I want to replace net.minecraft.util.ChatAllowedCharacters to make it possible (with checks) to enter the § symbol. How can i do this?
December 30, 20177 yr ASM/Core editing is not supported by Forge. A Moderator will likely lock this thread unless you change to a more viable solution. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
December 30, 20177 yr 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?
December 30, 20177 yr 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
December 30, 20177 yr 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.