MCrafterzz Posted June 15, 2016 Posted June 15, 2016 If you have the same problem then change it to this: @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; Style red = new Style().setColor(TextFormatting.DARK_RED); player.addChatComponentMessage(new TextComponentTranslation("commands.mm.name").setStyle(red)); } } I can't use coulour codes in lang, am I doing something wrong? commands.mm.name=§1Name: MCrafterzz Mod public class CommandMCrafterzzMod extends CommandBase { public CommandMCrafterzzMod() { } @Override public String getCommandName() { return "mcrafterzzmod"; } @Override public String getCommandUsage(ICommandSender sender) { return "mcrafterzzmod"; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; player.addChatComponentMessage(new TextComponentTranslation("commands.mm.name")); player.addChatComponentMessage(new TextComponentTranslation("commands.mm.modid")); player.addChatComponentMessage(new TextComponentTranslation("commands.mm.version")); player.addChatComponentMessage(new TextComponentTranslation("commands.mm.minecraftversion")); player.addChatComponentMessage(new TextComponentTranslation("commands.mm.creator")); player.addChatComponentMessage(new TextComponentTranslation("commands.mm.updatepage")); } } @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { return true; } @Override public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { return null; } } Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
MCrafterzz Posted June 15, 2016 Author Posted June 15, 2016 Thank you very much Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
MCrafterzz Posted June 15, 2016 Author Posted June 15, 2016 player.addChatComponentMessage((ITextComponent) new TextComponentTranslation("commands.mm.name").getStyle().setColor(TextFormatting.DARK_RED)); I changed it to this but then it said: A unknown error occured while attempting to perform this command Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
shadowfacts Posted June 15, 2016 Posted June 15, 2016 There should be a stack trace in the log, post it. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
MCrafterzz Posted June 16, 2016 Author Posted June 16, 2016 I know what casts do it converts it to what your casting and I thought that would work because it wants a textcomponent. I didn't know that you should have done it on a new line. Now you have learned me so I won't make this mistake again. I have only made minecraft mods for a couple of weeks so I don't know how to do everything. Thank you for your reply Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
MCrafterzz Posted June 16, 2016 Author Posted June 16, 2016 Why do use # Style#Setcolor for example instead of Style.SetColour (Colour) Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
MCrafterzz Posted June 16, 2016 Author Posted June 16, 2016 I've added this on it's own line: getStyle().setColor(TextFormatting.DARK_RED) but It sais create methoud getStyle Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
MCrafterzz Posted June 16, 2016 Author Posted June 16, 2016 I've added this, Ill se if it works: Style red = new Style().setColor(TextFormatting.DARK_RED); Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
MCrafterzz Posted June 16, 2016 Author Posted June 16, 2016 Worked thank you for everyones help Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod]
Botjoe Posted July 6, 2016 Posted July 6, 2016 Is it more correct to implement ICommand rather than extend CommandBase for this type of command? When would one not choose ICommand? Quote
Recommended Posts
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.