Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Feb 18, 2021
2 parents 77caa17 + dfc7eaa commit 9451619
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/main/java/com/hb/mcfdebugger/mixin/CommandSourceHook.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.hb.mcfdebugger.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.server.command.ServerCommandSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ServerCommandSource.class)
public class CommandSourceHook {
@Shadow @Final int level;
public int fakeGetLevel(){
return this.level;
public int fakeLevel;
@Inject(method="getEntity" ,at=@At("HEAD"))
public void fakeGetEntity(CallbackInfoReturnable ci) {
this.fakeLevel=level;
System.out.println(1234);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public static void send(CommandFunction.Element element, ServerCommandSource sou
sourceMap.put("rotation","("+source.getRotation().x+", "+source.getRotation().y+")");
sourceMap.put("world",source.getWorld().getRegistryKey().getValue().toString());
try {
Method levelMethod = source.getClass().getDeclaredMethod("fakeGetLevel");
sourceMap.put("level", String.valueOf(levelMethod.invoke(source)));
Field levelField = source.getClass().getDeclaredField("fakeLevel");
sourceMap.put("level",String.valueOf(levelField.get(element)));
} catch (ReflectiveOperationException e) {
sourceMap.put("level","Error");
DebugThread.sendObjMsgToDebugger(e.getMessage(),"e");
}
sourceMap.put("commandsLeftToMaxChainLength", String.valueOf(McfDebugger.commandsLeftToMaxChainLength));
SendCmdObj sendCmdObj = new SendCmdObj(funNamespace, funPath, cmdIndex, element.toString(),true,sourceMap);
Expand Down

0 comments on commit 9451619

Please sign in to comment.