Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import vakiliner.chatcomponentapi.component.ChatStyle;
import vakiliner.chatcomponentapi.component.ChatTextComponent;
import vakiliner.chatcomponentapi.component.ChatTranslateComponent;
import vakiliner.chatcomponentapi.fabric.mixin.StyleMixin;
import vakiliner.chatcomponentapi.fabric.mixin.StyleAccessor;

public class FabricParser extends BaseParser {
public boolean supportsSeparatorInSelector() {
Expand Down Expand Up @@ -139,24 +139,24 @@ public static ChatComponent fabric(Component raw) {
public static Style fabric(ChatStyle chatStyle) {
if (chatStyle == null) return null;
if (chatStyle.isEmpty()) return Style.EMPTY;
return StyleMixin.newStyle(fabric(chatStyle.getColor()), chatStyle.getBold(), chatStyle.getItalic(), chatStyle.getUnderlined(), chatStyle.getStrikethrough(), chatStyle.getObfuscated(), fabric(chatStyle.getClickEvent()), fabric(chatStyle.getHoverEvent()), chatStyle.getInsertion(), fabric(chatStyle.getFont()));
return StyleAccessor.newStyle(fabric(chatStyle.getColor()), chatStyle.getBold(), chatStyle.getItalic(), chatStyle.getUnderlined(), chatStyle.getStrikethrough(), chatStyle.getObfuscated(), fabric(chatStyle.getClickEvent()), fabric(chatStyle.getHoverEvent()), chatStyle.getInsertion(), fabric(chatStyle.getFont()));
}

public static ChatStyle fabric(Style style) {
if (style == null) return null;
if (style.isEmpty()) return ChatStyle.EMPTY;
StyleMixin mixin = (StyleMixin) style;
StyleAccessor accessor = (StyleAccessor) style;
ChatStyle.Builder builder = ChatStyle.newBuilder();
builder.withColor(fabric(style.getColor()));
builder.withBold(mixin.getBold());
builder.withItalic(mixin.getItalic());
builder.withUnderlined(mixin.getUnderlined());
builder.withStrikethrough(mixin.getStrikethrough());
builder.withObfuscated(mixin.getObfuscated());
builder.withClickEvent(fabric(style.getClickEvent()));
builder.withHoverEvent(fabric(mixin.getHoverEvent()));
builder.withInsertion(style.getInsertion());
builder.withFont(fabric(mixin.getFont()));
builder.withColor(fabric(accessor.getColor()));
builder.withBold(accessor.getBold());
builder.withItalic(accessor.getItalic());
builder.withUnderlined(accessor.getUnderlined());
builder.withStrikethrough(accessor.getStrikethrough());
builder.withObfuscated(accessor.getObfuscated());
builder.withClickEvent(fabric(accessor.getClickEvent()));
builder.withHoverEvent(fabric(accessor.getHoverEvent()));
builder.withInsertion(accessor.getInsertion());
builder.withFont(fabric(accessor.getFont()));
return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.resources.ResourceLocation;

@Mixin(Style.class)
public interface StyleMixin {
public interface StyleAccessor {
@Invoker("<init>")
static Style newStyle(TextColor textColor, Boolean bold, Boolean italic, Boolean underlined, Boolean strikethrough, Boolean obfuscated, ClickEvent clickEvent, HoverEvent hoverEvent, String insertion, ResourceLocation font) {
throw new AssertionError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import vakiliner.chatcomponentapi.component.ChatStyle;
import vakiliner.chatcomponentapi.component.ChatTextComponent;
import vakiliner.chatcomponentapi.component.ChatTranslateComponent;
import vakiliner.chatcomponentapi.forge.mixin.StyleMixin;
import vakiliner.chatcomponentapi.forge.mixin.StyleAccessor;

public class ForgeParser extends BaseParser {
public boolean supportsSeparatorInSelector() {
Expand Down Expand Up @@ -125,24 +125,24 @@ public static ChatComponent forge(ITextComponent raw) {
public static Style forge(ChatStyle chatStyle) {
if (chatStyle == null) return null;
if (chatStyle.isEmpty()) return Style.EMPTY;
return StyleMixin.newStyle(forge(chatStyle.getColor()), chatStyle.getBold(), chatStyle.getItalic(), chatStyle.getUnderlined(), chatStyle.getStrikethrough(), chatStyle.getObfuscated(), forge(chatStyle.getClickEvent()), forge(chatStyle.getHoverEvent()), chatStyle.getInsertion(), forge(chatStyle.getFont()));
return StyleAccessor.newStyle(forge(chatStyle.getColor()), chatStyle.getBold(), chatStyle.getItalic(), chatStyle.getUnderlined(), chatStyle.getStrikethrough(), chatStyle.getObfuscated(), forge(chatStyle.getClickEvent()), forge(chatStyle.getHoverEvent()), chatStyle.getInsertion(), forge(chatStyle.getFont()));
}

public static ChatStyle forge(Style style) {
if (style == null) return null;
if (style.isEmpty()) return ChatStyle.EMPTY;
StyleMixin mixin = (StyleMixin) style;
StyleAccessor accessor = (StyleAccessor) style;
ChatStyle.Builder builder = ChatStyle.newBuilder();
builder.withColor(forge(mixin.getColor()));
builder.withBold(mixin.getBold());
builder.withItalic(mixin.getItalic());
builder.withUnderlined(mixin.getUnderlined());
builder.withStrikethrough(mixin.getStrikethrough());
builder.withObfuscated(mixin.getObfuscated());
builder.withClickEvent(forge(mixin.getClickEvent()));
builder.withHoverEvent(forge(mixin.getHoverEvent()));
builder.withInsertion(mixin.getInsertion());
builder.withFont(forge(mixin.getFont()));
builder.withColor(forge(accessor.getColor()));
builder.withBold(accessor.getBold());
builder.withItalic(accessor.getItalic());
builder.withUnderlined(accessor.getUnderlined());
builder.withStrikethrough(accessor.getStrikethrough());
builder.withObfuscated(accessor.getObfuscated());
builder.withClickEvent(forge(accessor.getClickEvent()));
builder.withHoverEvent(forge(accessor.getHoverEvent()));
builder.withInsertion(accessor.getInsertion());
builder.withFont(forge(accessor.getFont()));
return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.util.text.event.HoverEvent;

@Mixin(Style.class)
public interface StyleMixin {
public interface StyleAccessor {
@Invoker("<init>")
static Style newStyle(Color сolor, Boolean bold, Boolean italic, Boolean underlined, Boolean strikethrough, Boolean obfuscated, ClickEvent clickEvent, HoverEvent hoverEvent, String insertion, ResourceLocation font) {
throw new AssertionError();
Expand Down