mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-18 17:03:55 +01:00
48 lines
1.7 KiB
Java
48 lines
1.7 KiB
Java
|
package com.simibubi.create.foundation.utility;
|
||
|
|
||
|
import net.minecraft.client.Minecraft;
|
||
|
import net.minecraft.util.text.StringTextComponent;
|
||
|
import net.minecraft.util.text.TextFormatting;
|
||
|
import net.minecraftforge.api.distmarker.Dist;
|
||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||
|
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||
|
|
||
|
/** Deprecated so simi doensn't forget to remove debug calls **/
|
||
|
@OnlyIn(value = Dist.CLIENT)
|
||
|
@Deprecated
|
||
|
public class Debug {
|
||
|
|
||
|
public static void debugChat(String message) {
|
||
|
if (Minecraft.getInstance().player != null)
|
||
|
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), false);
|
||
|
}
|
||
|
|
||
|
public static void debugChatAndShowStack(String message, int depth) {
|
||
|
if (Minecraft.getInstance().player != null)
|
||
|
Minecraft.getInstance().player
|
||
|
.sendStatusMessage(new StringTextComponent(message + " @" + debugStack(depth)), false);
|
||
|
}
|
||
|
|
||
|
public static void debugMessage(String message) {
|
||
|
if (Minecraft.getInstance().player != null)
|
||
|
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), true);
|
||
|
}
|
||
|
|
||
|
public static String getLogicalSide() {
|
||
|
return EffectiveSide.get().isClient() ? "CL" : "SV";
|
||
|
}
|
||
|
|
||
|
public static String debugStack(int depth) {
|
||
|
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||
|
String text = "[" + TextFormatting.GOLD + getLogicalSide() + TextFormatting.WHITE + "] ";
|
||
|
for (int i = 1; i < depth + 2 && i < stackTraceElements.length; i++) {
|
||
|
StackTraceElement e = stackTraceElements[i];
|
||
|
if (e.getClassName().equals(Debug.class.getName()))
|
||
|
continue;
|
||
|
text = text + TextFormatting.YELLOW + e.getMethodName() + TextFormatting.WHITE + ", ";
|
||
|
}
|
||
|
return text + TextFormatting.GRAY + " ...";
|
||
|
}
|
||
|
|
||
|
}
|