Skip to content

Commit 8dc0d7d

Browse files
committed
update to 1.21.10 and fix some bugs
1 parent 3709433 commit 8dc0d7d

File tree

8 files changed

+674
-0
lines changed

8 files changed

+674
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package net.gunivers.sniffer.mixin;
2+
3+
import net.minecraft.server.MinecraftServer;
4+
import net.minecraft.server.function.CommandFunctionManager;
5+
import org.slf4j.Logger;
6+
import org.spongepowered.asm.mixin.Final;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Shadow;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
13+
@Mixin(CommandFunctionManager.class)
14+
public class CommandFunctionManagerMixin {
15+
16+
@Shadow @Final private static Logger LOGGER;
17+
18+
@Shadow @Final private MinecraftServer server;
19+
20+
@Inject(method = "tick", at = @At("HEAD"))
21+
public void beforeTick(CallbackInfo ci){
22+
//TODO at every start of a tick, the stack should be empty
23+
// if(this.server.getTickManager().shouldTick()){
24+
// ScopeManager.get().clear();
25+
// }
26+
}
27+
28+
@Inject(method = "tick", at = @At("TAIL"))
29+
public void afterTick(CallbackInfo ci) {
30+
//TODO at the end of a tick, the stack should be empty too, or a leak has occurred
31+
// if(this.server.getTickManager().shouldTick()){
32+
// if(!ScopeManager.get().isEmpty()){
33+
// var scopes = new StringBuilder();
34+
// for (var scope: ScopeManager.get().getDebugScopes()){
35+
// scopes.append(scope.getFunction()).append('\n');
36+
// }
37+
// LOGGER.warn("A leak occurred! \n Current scopes: \n {}", scopes);
38+
// ScopeManager.get().clear();
39+
// }
40+
// }
41+
}
42+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package net.gunivers.sniffer.mixin;
2+
3+
import net.gunivers.sniffer.command.BreakPointCommand;
4+
import net.minecraft.command.CommandExecutionContext;
5+
import net.minecraft.command.FallthroughCommandAction;
6+
import net.minecraft.command.Frame;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
import static net.gunivers.sniffer.command.StepType.isStepOut;
13+
14+
@Mixin(FallthroughCommandAction.class)
15+
public class FallthroughCommandActionMixin<T> {
16+
@Inject(method = "execute", at = @At("HEAD"))
17+
private void onExecute(CommandExecutionContext<T> commandExecutionContext, Frame frame, CallbackInfo ci){
18+
if(BreakPointCommand.isDebugging && BreakPointCommand.moveSteps > 0 && !isStepOut()) {
19+
BreakPointCommand.moveSteps --;
20+
}
21+
}
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.gunivers.sniffer.mixin;
2+
3+
import com.llamalad7.mixinextras.sugar.Local;
4+
import net.gunivers.sniffer.command.BreakPointCommand;
5+
import net.minecraft.command.*;
6+
import net.minecraft.server.command.AbstractServerCommandSource;
7+
import org.objectweb.asm.Opcodes;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
13+
import java.util.List;
14+
15+
import static net.gunivers.sniffer.command.StepType.isStepOut;
16+
17+
@Mixin(SingleCommandAction.class)
18+
public class SingleCommandActionMixin<T extends AbstractServerCommandSource<T>> {
19+
20+
@Inject(method = "execute", at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 4))
21+
private void onExecute(
22+
T baseSource,
23+
List<T> sources,
24+
CommandExecutionContext<T> context,
25+
Frame frame,
26+
ExecutionFlags flags,
27+
CallbackInfo ci,
28+
@Local(ordinal = 1) ExecutionFlags executionFlags
29+
){
30+
if (!executionFlags.isInsideReturnRun()) {
31+
if(BreakPointCommand.isDebugging && BreakPointCommand.moveSteps > 0 && !isStepOut()) {
32+
BreakPointCommand.moveSteps --;
33+
}
34+
}
35+
}
36+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package net.gunivers.sniffer.util;
2+
3+
public enum ExceptionCode {
4+
REFLECT_INVOKE_EXCEPTION(0),
5+
NULL_POINTER_EXCEPTION(1);
6+
7+
private final int code;
8+
9+
ExceptionCode(int code) {
10+
this.code = code;
11+
}
12+
13+
public int getCode() {
14+
return code;
15+
}
16+
}

0 commit comments

Comments
 (0)