Skip to content

Commit

Permalink
support for 1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Aug 9, 2021
1 parent 912c6fc commit 5b22222
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 71 deletions.
58 changes: 32 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

dependencies {
minecraft "com.mojang:minecraft:21w11a"
mappings "net.fabricmc:yarn:21w11a+build.8:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.3"
//Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.32.4+1.17"
compile group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.1'
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "org.java-websocket:Java-WebSocket:1.5.1"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
Expand All @@ -33,13 +47,8 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

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

java {
Expand All @@ -53,9 +62,6 @@ jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

// configure the maven publication
Expand All @@ -72,11 +78,11 @@ publishing {
}
}

// Select the repositories you want to publish to
// To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
allprojects {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G

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

#Fabric api
fabric_version=0.32.4+1.17
# Dependencies
fabric_version=0.37.2+1.17

# Mod Properties
mod_version = 1.1.1
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/hb/mcfdebugger/config/ConfigHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class ConfigHolder {
public static String debuggerMode="none";
public static boolean isThisModDebugging=false;
public static boolean nonStopOnException = false;
public static boolean executeCmdStopAtSuccess=false;
public static void resetFeature(){
nonStopOnException = false;
isThisModDebugging=false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
package com.hb.mcfdebugger.mixin;

import com.google.common.collect.Queues;
import com.hb.mcfdebugger.McfDebugger;
import com.google.common.collect.Lists;
import com.hb.mcfdebugger.mixinHelpers.SendFunctionState;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.function.CommandFunction;
import net.minecraft.server.function.CommandFunctionManager;
import net.minecraft.server.function.FunctionLoader;
import net.minecraft.util.profiler.Profiler;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.Objects;

@Mixin(CommandFunctionManager.class)
/*@Mixin(CommandFunctionManager.Entry.class)
public abstract class CommandFunctionManagerHook {
@Shadow
boolean executing;
boolean justLoaded;
boolean executing = justLoaded;
@Shadow
@Final
MinecraftServer server;
Expand Down Expand Up @@ -94,5 +102,33 @@ public int execute(CommandFunction function, ServerCommandSource source) {
}
}
}
@Shadow @Final ServerCommandSource source;
@Shadow @Final int depth;
@Shadow @Final CommandFunction.Element element;
@Overwrite
public void execute(CommandFunctionManager manager, Deque<CommandFunctionManager.Entry> entries, int maxChainLength, @Nullable CommandFunctionManager.Tracer tracer) {
//modified
SendFunctionState.send(this.loader);
//modified
try {
CommandFunctionManager.Entry entry = (CommandFunctionManager.Entry) this.chain.removeFirst();
this.server.getProfiler().push(entry::toString);
//modified
McfDebugger.nowCommandCount = CommandFunctionManager.;
McfDebugger.commandsLeftToMaxChainLength = maxChainLength - j;
this.element.execute(manager, this.source, entries, maxChainLength, this.depth, tracer);
} catch (CommandSyntaxException var6) {
if (tracer != null) {
tracer.traceError(this.depth, var6.getRawMessage().getString());
}
} catch (Exception var7) {
if (tracer != null) {
tracer.traceError(this.depth, var7.getMessage());
}
}
}
}
*/
14 changes: 12 additions & 2 deletions src/main/java/com/hb/mcfdebugger/mixin/DebugHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.server.function.CommandFunction;
import net.minecraft.server.function.CommandFunctionManager;

import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -21,8 +22,10 @@
public abstract class DebugHook implements CommandFunction.Element{
CommandFunction.Element element=(CommandFunction.Element)this;
@Shadow @Final ParseResults<ServerCommandSource> parsed;
@Shadow
abstract int execute(CommandFunctionManager manager, ServerCommandSource source) throws CommandSyntaxException;
@Overwrite
public void execute (CommandFunctionManager manager, ServerCommandSource source, Deque<CommandFunctionManager.Entry> entries, int maxChainLength) throws CommandSyntaxException {
public void execute (CommandFunctionManager manager, ServerCommandSource source, Deque<CommandFunctionManager.Entry> entries, int maxChainLength, int depth, @Nullable CommandFunctionManager.Tracer tracer) throws CommandSyntaxException {
SendCommandState.send(element,source);
boolean isLastCmd=false;
try {
Expand All @@ -41,7 +44,14 @@ public void execute (CommandFunctionManager manager, ServerCommandSource source,
}
}
//origin
manager.getDispatcher().execute(new ParseResults(this.parsed.getContext().withSource(source), this.parsed.getReader(), this.parsed.getExceptions()));
if (tracer != null) {
String string = this.parsed.getReader().getString();
tracer.traceCommandStart(depth, string);
int i = this.execute(manager, source);
tracer.traceCommandEnd(depth, string, i);
} else {
this.execute(manager, source);
}
//origin

}
Expand Down
60 changes: 36 additions & 24 deletions src/main/java/com/hb/mcfdebugger/mixin/ErrorHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.hb.mcfdebugger.*;
import com.hb.mcfdebugger.config.ConfigHolder;
import com.hb.mcfdebugger.mixinHelpers.ReadCommandSource;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.function.CommandFunction;
import net.minecraft.server.function.CommandFunctionManager;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -14,45 +16,55 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedHashMap;
import java.util.Map;

@Mixin(CommandFunctionManager.Entry.class)
public class ErrorHook {
@Shadow @Final CommandFunctionManager manager;
@Shadow @Final ServerCommandSource source;
@Shadow @Final int depth;
@Shadow @Final CommandFunction.Element element;
@Overwrite
public void execute(ArrayDeque<CommandFunctionManager.Entry> stack, int maxChainLength) {
public void execute(CommandFunctionManager manager, Deque<CommandFunctionManager.Entry> entries, int maxChainLength, @Nullable CommandFunctionManager.Tracer tracer) {
try {
element.execute(manager, source, stack, maxChainLength);
} catch (Throwable var4) {
if (!ConfigHolder.debuggerMode.equals("none")) {
String exceptionMsg = var4.toString();
if (exceptionMsg != "") {
if (McfDebugger.lastCmdObj!=null && !McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
sendError(exceptionMsg,ConfigHolder.nonStopOnException?1:0);

}
}
this.element.execute(manager, this.source, entries, maxChainLength, this.depth, tracer);
} catch (CommandSyntaxException var6) {
if (tracer != null) {
tracer.traceError(this.depth, var6.getRawMessage().getString());
}
sendError(var6);
} catch (Exception var7) {
if (tracer != null) {
tracer.traceError(this.depth, var7.getMessage());
}
sendError(var7);
}
if (McfDebugger.lastCmdObj!=null && McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
McfDebugger.nowMuteCmd.clear();
}
}
public void sendError(String message,int mode) {
McfDebugger.lastCmdObj.exception=message;
McfDebugger.lastCmdObj.pause=true;
SendCmdObj sendCmdObj = new SendCmdObj(McfDebugger.lastCmdObj.funNamespace, McfDebugger.lastCmdObj.funPath, McfDebugger.lastCmdObj.cmdIndex, element.toString(),true, ReadCommandSource.read(source));
sendCmdObj.exception=message;
if(mode==0||McfDebugger.howeverStop){
McfDebugger.howeverStop=false;
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
DebugThread.sendObjMsgToDebugger(sendCmdObj,"errorCommandReport");
PauseWaiter.WaitForNext();
}else if (mode==1){
DebugThread.sendObjMsgToDebugger(sendCmdObj,"nonStopErrorCommandReport");
public void sendError(Exception exception) {
if (!ConfigHolder.debuggerMode.equals("none")) {
String exceptionMsg = exception.toString();
if (exceptionMsg != "") {
if (McfDebugger.lastCmdObj!=null && !McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
int mode=ConfigHolder.nonStopOnException?1:0;
McfDebugger.lastCmdObj.exception=exceptionMsg;
McfDebugger.lastCmdObj.pause=true;
SendCmdObj sendCmdObj = new SendCmdObj(McfDebugger.lastCmdObj.funNamespace, McfDebugger.lastCmdObj.funPath, McfDebugger.lastCmdObj.cmdIndex, element.toString(),true, ReadCommandSource.read(source));
sendCmdObj.exception=exceptionMsg;
if(mode==0||McfDebugger.howeverStop){
McfDebugger.howeverStop=false;
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
DebugThread.sendObjMsgToDebugger(sendCmdObj,"errorCommandReport");
PauseWaiter.WaitForNext();
}else if (mode==1){
DebugThread.sendObjMsgToDebugger(sendCmdObj,"nonStopErrorCommandReport");
}
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static int execute(ServerCommandSource source, Collection<CommandFunctio
CommandFunction commandFunction;
McfDebugger.lastCallCmdObj = McfDebugger.lastCmdObj==null?null:McfDebugger.lastCmdObj;
McfDebugger.tagFunctionLeft.add(functions.size());
for (Iterator var3 = functions.iterator(); var3.hasNext(); i += source.getMinecraftServer().getCommandFunctionManager().execute(commandFunction, source.withSilent().withMaxLevel(2))) {
for (Iterator var3 = functions.iterator(); var3.hasNext(); i += source.getServer().getCommandFunctionManager().execute(commandFunction, source.withSilent().withMaxLevel(2))) {

commandFunction = (CommandFunction) var3.next();
//modified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceReloadListener;
import net.minecraft.resource.ResourceReloader;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.server.command.ServerCommandSource;
Expand Down Expand Up @@ -39,7 +39,7 @@
import com.hb.mcfdebugger.mixinHelpers.FakeCommandFunctionCreate;

@Mixin(FunctionLoader.class)
public abstract class FunctionLoaderHook implements ResourceReloadListener{
public abstract class FunctionLoaderHook implements ResourceReloader {
@Shadow @Final TagGroupLoader<CommandFunction> tagLoader;
@Shadow abstract Optional<CommandFunction> get(Identifier id);
private static final int PATH_PREFIX_LENGTH = "functions/".length();
Expand All @@ -51,7 +51,7 @@ public abstract class FunctionLoaderHook implements ResourceReloadListener{
@Shadow @Final int level;

@Overwrite
public CompletableFuture<Void> reload(ResourceReloadListener.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) {
public CompletableFuture<Void> reload(ResourceReloader.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) {
CompletableFuture<Map<Identifier, Tag.Builder>> completableFuture = CompletableFuture.supplyAsync(() -> {
return this.tagLoader.loadTags(manager);
}, prepareExecutor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Map;

public class SendFunctionState {
public static void send(FunctionLoader f, CommandSource source, CommandFunction function) {
public static void send(FunctionLoader f) {
Map<Identifier, CommandFunction> funMap = f.getFunctions();
List<McfDebugger.HbCmdObj> a = funObjParse(funMap);
DebugThread.sendObjMsgToDebugger(a, "functionList");
Expand Down
Loading

0 comments on commit 5b22222

Please sign in to comment.