Skip to content

Commit

Permalink
1.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
3093FengMing committed Jan 20, 2023
1 parent f41c1f5 commit 4145232
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void readConfig() throws IOException {
writeConfig(jw);
}

JsonReader jr = GSON.newJsonReader(Files.newBufferedReader(configFile));
JsonReader jr = GSON.newJsonReader(new InputStreamReader(new FileInputStream(f)));

jr.beginObject();
while (jr.peek() != JsonToken.END_OBJECT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import net.minecraft.server.Bootstrap;
import net.minecraftforge.fml.loading.FMLPaths;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
Expand Down Expand Up @@ -60,7 +62,7 @@ public void readConfig() throws IOException {
if (Files.notExists(patchFile)) {
Files.createFile(patchFile);
}
try (var jsonReader = GSON.newJsonReader(Files.newBufferedReader(patchFile))) {
try (var jsonReader = GSON.newJsonReader(new InputStreamReader(new FileInputStream(patchFile.toFile())))) {
readConfig(jsonReader);
}
}
Expand Down Expand Up @@ -99,8 +101,10 @@ public String patch(String text, StackTraceElement[] stackTrace) {
return null;
}

private boolean matchStack(String str, StackTraceElement[] stackTrace) {
private boolean matchStack(String str, StackTraceElement[] stack) {
String s = str.toLowerCase();
List<StackTraceElement> stackTrace = Arrays.stream(stack).toList();
stackTrace = stackTrace.subList(7, stackTrace.size() - 13);
for (StackTraceElement ste : stackTrace) {
if (s.startsWith("#")) {
return ste.getClassName().endsWith(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

import me.fengming.vaultpatcher.ThePatcher;
import net.minecraft.network.chat.*;
import net.minecraft.util.FormattedCharSequence;
import org.apache.commons.compress.utils.Lists;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;
Expand All @@ -35,6 +32,10 @@ private void proxy_getSiblings(CallbackInfoReturnable<List<Component>> cir) {
}
*/

@Shadow public abstract MutableComponent copy();

@Shadow @Final protected List<Component> siblings;

@ModifyArg(
method = "getVisualOrderText",
at = @At(
Expand All @@ -46,6 +47,19 @@ private FormattedText proxy_getVisualOrder(FormattedText p_128116_) {
if (p_128116_ instanceof TextComponent) {
String c = ThePatcher.patch(p_128116_.getString());
return new TextComponent(c);
} else return p_128116_;
}
return p_128116_;
}

@Inject(
method = "append",
at = @At("HEAD"),
cancellable = true
)
private void proxy_append(Component p_130585_, CallbackInfoReturnable<MutableComponent> cir) {
String c = ThePatcher.patch(p_130585_.getString());
this.siblings.add(new TextComponent(c));
cir.setReturnValue(this.copy());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

import me.fengming.vaultpatcher.ThePatcher;
import net.minecraft.network.chat.TextComponent;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import static me.fengming.vaultpatcher.VaultPatcher.exportList;

@Mixin(value = TextComponent.class, priority = Integer.MAX_VALUE)
public abstract class TextComponentMixin {

@Accessor("text")
abstract String getText1();

Expand Down

0 comments on commit 4145232

Please sign in to comment.