Skip to content

Commit 5b22222

Browse files
committed
support for 1.17.1
1 parent 912c6fc commit 5b22222

16 files changed

Lines changed: 139 additions & 71 deletions

build.gradle

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
plugins {
2-
id 'fabric-loom' version '0.5-SNAPSHOT'
2+
id 'fabric-loom' version '0.8-SNAPSHOT'
33
id 'maven-publish'
44
}
55

6-
sourceCompatibility = JavaVersion.VERSION_1_8
7-
targetCompatibility = JavaVersion.VERSION_1_8
6+
sourceCompatibility = JavaVersion.VERSION_16
7+
targetCompatibility = JavaVersion.VERSION_16
88

99
archivesBaseName = project.archives_base_name
1010
version = project.mod_version
1111
group = project.maven_group
1212

13+
repositories {
14+
// Add repositories to retrieve artifacts from in here.
15+
// You should only use this when depending on other mods because
16+
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
17+
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
18+
// for more information about repositories.
19+
}
20+
1321
dependencies {
14-
minecraft "com.mojang:minecraft:21w11a"
15-
mappings "net.fabricmc:yarn:21w11a+build.8:v2"
16-
modImplementation "net.fabricmc:fabric-loader:0.11.3"
17-
//Fabric api
18-
modImplementation "net.fabricmc.fabric-api:fabric-api:0.32.4+1.17"
19-
compile group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.1'
22+
// To change the versions see the gradle.properties file
23+
minecraft "com.mojang:minecraft:${project.minecraft_version}"
24+
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
25+
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
26+
27+
// Fabric API. This is technically optional, but you probably want it anyway.
28+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
29+
implementation "org.java-websocket:Java-WebSocket:1.5.1"
30+
31+
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
32+
// You may need to force-disable transitiveness on them.
2033
}
2134

2235
processResources {
2336
inputs.property "version", project.version
37+
2438
filesMatching("fabric.mod.json") {
2539
expand "version": project.version
2640
}
@@ -33,13 +47,8 @@ tasks.withType(JavaCompile).configureEach {
3347
// If Javadoc is generated, this must be specified in that task too.
3448
it.options.encoding = "UTF-8"
3549

36-
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
37-
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
38-
// We'll use that if it's available, but otherwise we'll use the older option.
39-
def targetVersion = 8
40-
if (JavaVersion.current().isJava9Compatible()) {
41-
it.options.release = targetVersion
42-
}
50+
// Minecraft 1.17 (21w19a) upwards uses Java 16.
51+
it.options.release = 16
4352
}
4453

4554
java {
@@ -53,9 +62,6 @@ jar {
5362
from("LICENSE") {
5463
rename { "${it}_${project.archivesBaseName}"}
5564
}
56-
from {
57-
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
58-
}
5965
}
6066

6167
// configure the maven publication
@@ -72,11 +78,11 @@ publishing {
7278
}
7379
}
7480

75-
// Select the repositories you want to publish to
76-
// To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
77-
allprojects {
78-
repositories {
79-
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
80-
}
81-
}
81+
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
82+
repositories {
83+
// Add repositories to publish to here.
84+
// Notice: This block does NOT have the same function as the block in the top level.
85+
// The repositories here will be used for publishing your artifact, not for
86+
// retrieving dependencies.
87+
}
8288
}

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
5-
# check these on https://fabricmc.net/use
6-
minecraft_version=21w11a
7-
yarn_mappings=21w11a+build.8
8-
loader_version=0.11.3
5+
# check these on https://fabricmc.net/versions.html
6+
minecraft_version=1.17.1
7+
yarn_mappings=1.17.1+build.35
8+
loader_version=0.11.6
99

10-
#Fabric api
11-
fabric_version=0.32.4+1.17
10+
# Dependencies
11+
fabric_version=0.37.2+1.17
1212

1313
# Mod Properties
1414
mod_version = 1.1.1

gradle/wrapper/gradle-wrapper.jar

333 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pluginManagement {
22
repositories {
3-
jcenter()
43
maven {
54
name = 'Fabric'
65
url = 'https://maven.fabricmc.net/'

src/main/java/com/hb/mcfdebugger/config/ConfigHolder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class ConfigHolder {
44
public static String debuggerMode="none";
55
public static boolean isThisModDebugging=false;
66
public static boolean nonStopOnException = false;
7+
public static boolean executeCmdStopAtSuccess=false;
78
public static void resetFeature(){
89
nonStopOnException = false;
910
isThisModDebugging=false;

src/main/java/com/hb/mcfdebugger/mixin/CommandFunctionManagerHook.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
package com.hb.mcfdebugger.mixin;
22

3+
import com.google.common.collect.Queues;
34
import com.hb.mcfdebugger.McfDebugger;
45
import com.google.common.collect.Lists;
56
import com.hb.mcfdebugger.mixinHelpers.SendFunctionState;
7+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
68
import net.minecraft.server.MinecraftServer;
79
import net.minecraft.server.command.ServerCommandSource;
810
import net.minecraft.server.function.CommandFunction;
911
import net.minecraft.server.function.CommandFunctionManager;
1012
import net.minecraft.server.function.FunctionLoader;
13+
import net.minecraft.util.profiler.Profiler;
14+
import org.jetbrains.annotations.Nullable;
1115
import org.spongepowered.asm.mixin.Final;
1216
import org.spongepowered.asm.mixin.Mixin;
1317
import org.spongepowered.asm.mixin.Overwrite;
1418
import org.spongepowered.asm.mixin.Shadow;
19+
import org.spongepowered.asm.mixin.injection.Redirect;
1520

1621
import java.util.ArrayDeque;
22+
import java.util.Deque;
1723
import java.util.List;
24+
import java.util.Objects;
1825

19-
@Mixin(CommandFunctionManager.class)
26+
/*@Mixin(CommandFunctionManager.Entry.class)
2027
public abstract class CommandFunctionManagerHook {
2128
2229
@Shadow
23-
boolean executing;
30+
boolean justLoaded;
31+
boolean executing = justLoaded;
2432
@Shadow
2533
@Final
2634
MinecraftServer server;
@@ -94,5 +102,33 @@ public int execute(CommandFunction function, ServerCommandSource source) {
94102
}
95103
}
96104
}
105+
@Shadow @Final ServerCommandSource source;
106+
@Shadow @Final int depth;
107+
@Shadow @Final CommandFunction.Element element;
108+
@Overwrite
109+
public void execute(CommandFunctionManager manager, Deque<CommandFunctionManager.Entry> entries, int maxChainLength, @Nullable CommandFunctionManager.Tracer tracer) {
110+
//modified
111+
SendFunctionState.send(this.loader);
112+
//modified
113+
try {
114+
CommandFunctionManager.Entry entry = (CommandFunctionManager.Entry) this.chain.removeFirst();
115+
this.server.getProfiler().push(entry::toString);
116+
//modified
117+
McfDebugger.nowCommandCount = CommandFunctionManager.;
118+
McfDebugger.commandsLeftToMaxChainLength = maxChainLength - j;
119+
this.element.execute(manager, this.source, entries, maxChainLength, this.depth, tracer);
120+
} catch (CommandSyntaxException var6) {
121+
if (tracer != null) {
122+
tracer.traceError(this.depth, var6.getRawMessage().getString());
123+
}
124+
} catch (Exception var7) {
125+
if (tracer != null) {
126+
tracer.traceError(this.depth, var7.getMessage());
127+
}
128+
}
129+
130+
}
131+
97132
98133
}
134+
*/

src/main/java/com/hb/mcfdebugger/mixin/DebugHook.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minecraft.server.function.CommandFunction;
1313
import net.minecraft.server.function.CommandFunctionManager;
1414

15+
import org.jetbrains.annotations.Nullable;
1516
import org.spongepowered.asm.mixin.Final;
1617
import org.spongepowered.asm.mixin.Mixin;
1718
import org.spongepowered.asm.mixin.Overwrite;
@@ -21,8 +22,10 @@
2122
public abstract class DebugHook implements CommandFunction.Element{
2223
CommandFunction.Element element=(CommandFunction.Element)this;
2324
@Shadow @Final ParseResults<ServerCommandSource> parsed;
25+
@Shadow
26+
abstract int execute(CommandFunctionManager manager, ServerCommandSource source) throws CommandSyntaxException;
2427
@Overwrite
25-
public void execute (CommandFunctionManager manager, ServerCommandSource source, Deque<CommandFunctionManager.Entry> entries, int maxChainLength) throws CommandSyntaxException {
28+
public void execute (CommandFunctionManager manager, ServerCommandSource source, Deque<CommandFunctionManager.Entry> entries, int maxChainLength, int depth, @Nullable CommandFunctionManager.Tracer tracer) throws CommandSyntaxException {
2629
SendCommandState.send(element,source);
2730
boolean isLastCmd=false;
2831
try {
@@ -41,7 +44,14 @@ public void execute (CommandFunctionManager manager, ServerCommandSource source,
4144
}
4245
}
4346
//origin
44-
manager.getDispatcher().execute(new ParseResults(this.parsed.getContext().withSource(source), this.parsed.getReader(), this.parsed.getExceptions()));
47+
if (tracer != null) {
48+
String string = this.parsed.getReader().getString();
49+
tracer.traceCommandStart(depth, string);
50+
int i = this.execute(manager, source);
51+
tracer.traceCommandEnd(depth, string, i);
52+
} else {
53+
this.execute(manager, source);
54+
}
4555
//origin
4656

4757
}

src/main/java/com/hb/mcfdebugger/mixin/ErrorHook.java

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import com.hb.mcfdebugger.*;
44
import com.hb.mcfdebugger.config.ConfigHolder;
55
import com.hb.mcfdebugger.mixinHelpers.ReadCommandSource;
6+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
67
import net.minecraft.server.command.ServerCommandSource;
78
import net.minecraft.server.function.CommandFunction;
89
import net.minecraft.server.function.CommandFunctionManager;
10+
import org.jetbrains.annotations.Nullable;
911
import org.spongepowered.asm.mixin.Final;
1012
import org.spongepowered.asm.mixin.Mixin;
1113
import org.spongepowered.asm.mixin.Overwrite;
@@ -14,45 +16,55 @@
1416
import java.lang.reflect.Field;
1517
import java.lang.reflect.Method;
1618
import java.util.ArrayDeque;
19+
import java.util.Deque;
1720
import java.util.LinkedHashMap;
1821
import java.util.Map;
1922

2023
@Mixin(CommandFunctionManager.Entry.class)
2124
public class ErrorHook {
22-
@Shadow @Final CommandFunctionManager manager;
2325
@Shadow @Final ServerCommandSource source;
26+
@Shadow @Final int depth;
2427
@Shadow @Final CommandFunction.Element element;
2528
@Overwrite
26-
public void execute(ArrayDeque<CommandFunctionManager.Entry> stack, int maxChainLength) {
29+
public void execute(CommandFunctionManager manager, Deque<CommandFunctionManager.Entry> entries, int maxChainLength, @Nullable CommandFunctionManager.Tracer tracer) {
2730
try {
28-
element.execute(manager, source, stack, maxChainLength);
29-
} catch (Throwable var4) {
30-
if (!ConfigHolder.debuggerMode.equals("none")) {
31-
String exceptionMsg = var4.toString();
32-
if (exceptionMsg != "") {
33-
if (McfDebugger.lastCmdObj!=null && !McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
34-
sendError(exceptionMsg,ConfigHolder.nonStopOnException?1:0);
35-
36-
}
37-
}
31+
this.element.execute(manager, this.source, entries, maxChainLength, this.depth, tracer);
32+
} catch (CommandSyntaxException var6) {
33+
if (tracer != null) {
34+
tracer.traceError(this.depth, var6.getRawMessage().getString());
35+
}
36+
sendError(var6);
37+
} catch (Exception var7) {
38+
if (tracer != null) {
39+
tracer.traceError(this.depth, var7.getMessage());
3840
}
41+
sendError(var7);
3942
}
4043
if (McfDebugger.lastCmdObj!=null && McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
4144
McfDebugger.nowMuteCmd.clear();
4245
}
4346
}
44-
public void sendError(String message,int mode) {
45-
McfDebugger.lastCmdObj.exception=message;
46-
McfDebugger.lastCmdObj.pause=true;
47-
SendCmdObj sendCmdObj = new SendCmdObj(McfDebugger.lastCmdObj.funNamespace, McfDebugger.lastCmdObj.funPath, McfDebugger.lastCmdObj.cmdIndex, element.toString(),true, ReadCommandSource.read(source));
48-
sendCmdObj.exception=message;
49-
if(mode==0||McfDebugger.howeverStop){
50-
McfDebugger.howeverStop=false;
51-
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
52-
DebugThread.sendObjMsgToDebugger(sendCmdObj,"errorCommandReport");
53-
PauseWaiter.WaitForNext();
54-
}else if (mode==1){
55-
DebugThread.sendObjMsgToDebugger(sendCmdObj,"nonStopErrorCommandReport");
47+
public void sendError(Exception exception) {
48+
if (!ConfigHolder.debuggerMode.equals("none")) {
49+
String exceptionMsg = exception.toString();
50+
if (exceptionMsg != "") {
51+
if (McfDebugger.lastCmdObj!=null && !McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
52+
int mode=ConfigHolder.nonStopOnException?1:0;
53+
McfDebugger.lastCmdObj.exception=exceptionMsg;
54+
McfDebugger.lastCmdObj.pause=true;
55+
SendCmdObj sendCmdObj = new SendCmdObj(McfDebugger.lastCmdObj.funNamespace, McfDebugger.lastCmdObj.funPath, McfDebugger.lastCmdObj.cmdIndex, element.toString(),true, ReadCommandSource.read(source));
56+
sendCmdObj.exception=exceptionMsg;
57+
if(mode==0||McfDebugger.howeverStop){
58+
McfDebugger.howeverStop=false;
59+
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
60+
DebugThread.sendObjMsgToDebugger(sendCmdObj,"errorCommandReport");
61+
PauseWaiter.WaitForNext();
62+
}else if (mode==1){
63+
DebugThread.sendObjMsgToDebugger(sendCmdObj,"nonStopErrorCommandReport");
64+
}
65+
}
66+
}
5667
}
68+
5769
}
5870
}

0 commit comments

Comments
 (0)