mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-15 02:20:05 +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:
parent
9ce33f8a3f
commit
c8a6888a2f
@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||
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 final class CommandCopy
|
||||
|
||||
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" ) ) ) );
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,12 @@ public final class 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 final class ChatHelpers
|
||||
{
|
||||
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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user