1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-29 00:23:23 +00:00

Fix styles not being saved

Styles have been changed to be immutable, meaning that we were never
updating them! Fixes #499.
This commit is contained in:
SquidDev 2020-07-25 11:19:04 +01:00
parent 9ce33f8a3f
commit c8a6888a2f
2 changed files with 9 additions and 12 deletions

View File

@ -12,6 +12,7 @@
import net.minecraft.command.CommandSource;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
@ -57,10 +58,8 @@ public static void onClientSendMessage( ClientChatEvent event )
public static ITextComponent createCopyText( String text )
{
StringTextComponent name = new StringTextComponent( text );
name.getStyle()
return new StringTextComponent( text ).func_230530_a_( Style.EMPTY
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) );
return name;
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) ) );
}
}

View File

@ -21,14 +21,12 @@ private ChatHelpers() {}
public static IFormattableTextComponent coloured( String text, TextFormatting colour )
{
IFormattableTextComponent component = new StringTextComponent( text == null ? "" : text );
component.getStyle().setFormatting( colour );
return component;
return new StringTextComponent( text == null ? "" : text ).func_240699_a_( colour );
}
public static <T extends IFormattableTextComponent> T coloured( T component, TextFormatting colour )
{
component.getStyle().setFormatting( colour );
component.func_240699_a_( colour );
return component;
}
@ -74,11 +72,11 @@ public static IFormattableTextComponent link( IFormattableTextComponent componen
{
Style style = component.getStyle();
if( style.getColor() == null ) style.setFormatting( TextFormatting.YELLOW );
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
if( style.getColor() == null ) style = style.setFormatting( TextFormatting.YELLOW );
style = style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
style = style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
return component;
return component.func_230530_a_( style );
}
public static IFormattableTextComponent header( String text )