Skip to content

Commit

Permalink
use mixin invoker on FontRenderer class instead of copy pasting vanil…
Browse files Browse the repository at this point in the history
…la code
  • Loading branch information
Alexdoru committed Sep 16, 2023
1 parent 21b70bc commit d161b0d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 48 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ public enum Mixins {
.addMixinClasses("minecraft.MixinGuiContainerCreative").setSide(Side.CLIENT)
.setApplyIf(() -> Common.config.removeCreativeSearchTab).addTargetedMod(TargetedMod.VANILLA)),
FIX_CHAT_COLOR_WRAPPING(new Builder("Fix wrapped chat lines missing colors").setPhase(Phase.EARLY)
.addMixinClasses("minecraft.MixinGuiNewChat_FixColorWrapping").setSide(Side.CLIENT)
.setApplyIf(() -> Common.config.fixChatWrappedColors).addTargetedMod(TargetedMod.VANILLA)),
.addMixinClasses("minecraft.MixinGuiNewChat_FixColorWrapping", "minecraft.FontRendererAccessor")
.setSide(Side.CLIENT).setApplyIf(() -> Common.config.fixChatWrappedColors)
.addTargetedMod(TargetedMod.VANILLA)),

// Ic2 adjustments
IC2_UNPROTECTED_GET_BLOCK_FIX(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.client.gui.FontRenderer;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(FontRenderer.class)
public interface FontRendererAccessor {

@Invoker("getFormatFromString")
static String callGetFormatFromString(String s) {
throw new IllegalStateException("Mixin stub invoked");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import com.mitchej123.hodgepodge.util.StringUtil;

@Mixin(GuiNewChat.class)
public class MixinGuiNewChat_FixColorWrapping {

Expand Down Expand Up @@ -37,7 +35,7 @@ public class MixinGuiNewChat_FixColorWrapping {
shift = At.Shift.BEFORE),
name = "s2")
private String hodgepodge$fixColorWrapping(String s2) {
return StringUtil.getFormatFromString(this.hodgepodge$s1) + s2;
return FontRendererAccessor.callGetFormatFromString(this.hodgepodge$s1) + s2;
}

}
43 changes: 0 additions & 43 deletions src/main/java/com/mitchej123/hodgepodge/util/StringUtil.java

This file was deleted.

0 comments on commit d161b0d

Please sign in to comment.