mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-11-17 15:24:52 +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.command.CommandSource;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.Style;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.util.text.event.ClickEvent;
|
import net.minecraft.util.text.event.ClickEvent;
|
||||||
import net.minecraft.util.text.event.HoverEvent;
|
import net.minecraft.util.text.event.HoverEvent;
|
||||||
@ -57,10 +58,8 @@ public final class CommandCopy
|
|||||||
|
|
||||||
public static ITextComponent createCopyText( String text )
|
public static ITextComponent createCopyText( String text )
|
||||||
{
|
{
|
||||||
StringTextComponent name = new StringTextComponent( text );
|
return new StringTextComponent( text ).func_230530_a_( Style.EMPTY
|
||||||
name.getStyle()
|
|
||||||
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
||||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) );
|
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) ) );
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,12 @@ public final class ChatHelpers
|
|||||||
|
|
||||||
public static IFormattableTextComponent coloured( String text, TextFormatting colour )
|
public static IFormattableTextComponent coloured( String text, TextFormatting colour )
|
||||||
{
|
{
|
||||||
IFormattableTextComponent component = new StringTextComponent( text == null ? "" : text );
|
return new StringTextComponent( text == null ? "" : text ).func_240699_a_( colour );
|
||||||
component.getStyle().setFormatting( colour );
|
|
||||||
return component;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IFormattableTextComponent> T coloured( T component, TextFormatting colour )
|
public static <T extends IFormattableTextComponent> T coloured( T component, TextFormatting colour )
|
||||||
{
|
{
|
||||||
component.getStyle().setFormatting( colour );
|
component.func_240699_a_( colour );
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,11 +72,11 @@ public final class ChatHelpers
|
|||||||
{
|
{
|
||||||
Style style = component.getStyle();
|
Style style = component.getStyle();
|
||||||
|
|
||||||
if( style.getColor() == null ) style.setFormatting( TextFormatting.YELLOW );
|
if( style.getColor() == null ) style = style.setFormatting( TextFormatting.YELLOW );
|
||||||
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
style = style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||||
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
style = style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||||
|
|
||||||
return component;
|
return component.func_230530_a_( style );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IFormattableTextComponent header( String text )
|
public static IFormattableTextComponent header( String text )
|
||||||
|
Loading…
Reference in New Issue
Block a user