diff --git a/src/main/java/com/hb/mcfdebugger/mixin/CommandSourceHook.java b/src/main/java/com/hb/mcfdebugger/mixin/CommandSourceHook.java index 71f2783..90e3847 100644 --- a/src/main/java/com/hb/mcfdebugger/mixin/CommandSourceHook.java +++ b/src/main/java/com/hb/mcfdebugger/mixin/CommandSourceHook.java @@ -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); } } diff --git a/src/main/java/com/hb/mcfdebugger/mixinHelpers/SendCommandState.java b/src/main/java/com/hb/mcfdebugger/mixinHelpers/SendCommandState.java index ea9ecaf..cd7a422 100644 --- a/src/main/java/com/hb/mcfdebugger/mixinHelpers/SendCommandState.java +++ b/src/main/java/com/hb/mcfdebugger/mixinHelpers/SendCommandState.java @@ -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);