Skip to content

Commit

Permalink
update to 1.21.3 and add chunk debug keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Boxadactle committed Oct 28, 2024
1 parent 2292f00 commit a609507
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 63 deletions.
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
## Changes
- Rewritten for 1.20.1
- Fixed config saving bug
- Allow debug help translations in all languages
- Added button tooltips to debug key screen
- Added /f3 command
- Added 1.20.6+ forge support
- Support for 1.21.3
- Checks chunkDebugKeys (whatever those are) when checking debug keys

## New Features
- Added profiler chart toggle key
- Added FPS charts toggle key
- Added network charts toggle key
- Added chunk section path key
- added fog toggle key
- added smart culling toggle key
- added frustum octree toggle key
- added frustum capture key
- added section visibility toggle key
- added wireframe toggle key
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public static BCommand create() {
.registerSubcommand(new DebugSubcommand("dump_textures", DebugKeybinds.DUMP_DYNAMIC_TEXTURES))
.registerSubcommand(new DebugSubcommand("gamemode", DebugKeybinds.OPEN_GAMEMODE_SWITCHER))
.registerSubcommand(new DebugSubcommand("clear_chat", DebugKeybinds.CLEAR_CHAT))
.registerSubcommand(new DebugSubcommand("pause_menuless", DebugKeybinds.PAUSE_WITHOUT_MENU));
.registerSubcommand(new DebugSubcommand("pause_menuless", DebugKeybinds.PAUSE_WITHOUT_MENU))
.registerSubcommand(new DebugSubcommand("capture_frustum", DebugKeybinds.CAPTURE_FRUSTUM))
.registerSubcommand(new DebugSubcommand("chunk_section_path", DebugKeybinds.CHUNK_SECTION_PATH));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ public static BSubcommand create() {
.registerSubcommand(new DebugSubcommand("chunk_borders", DebugKeybinds.CHUNK_BORDERS))
.registerSubcommand(new DebugSubcommand("advanced_tooltips", DebugKeybinds.ADVANCED_TOOLTIPS))
.registerSubcommand(new DebugSubcommand("pause_on_lost_focus", DebugKeybinds.PAUSE_FOCUS))
.registerSubcommand(new DebugSubcommand("profiling", DebugKeybinds.PROFILING));
.registerSubcommand(new DebugSubcommand("profiling", DebugKeybinds.PROFILING))
.registerSubcommand(new DebugSubcommand("profiler_chart", DebugKeybinds.TOGGLE_PROFILER_CHART))
.registerSubcommand(new DebugSubcommand("fps_charts", DebugKeybinds.TOGGLE_FPS_CHARTS))
.registerSubcommand(new DebugSubcommand("network_charts", DebugKeybinds.TOGGLE_NETWORK_CHARTS))
.registerSubcommand(new DebugSubcommand("fog", DebugKeybinds.TOGGLE_FOG))
.registerSubcommand(new DebugSubcommand("smart_cull", DebugKeybinds.TOGGLE_SMART_CULL))
.registerSubcommand(new DebugSubcommand("frustum_octree", DebugKeybinds.TOGGLE_FRUSTUM_OCTREE))
.registerSubcommand(new DebugSubcommand("section_visibility", DebugKeybinds.TOGGLE_SECTION_VISIBILITY))
.registerSubcommand(new DebugSubcommand("wireframe", DebugKeybinds.TOGGLE_WIREFRAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class DebugKeybinds {
public static GlobalKeybind DEBUG = createGlobalKeybind("key.debug.debugkeybind", 292);
public static GlobalKeybind HIDE_GUI = createGlobalKeybind("key.debug.hide_gui", 290);

public static ActionKeybind TOGGLE_PROFILER_CHART = createActionKeybind("key.debug_actions.toggle_profiler_chart", 49);
public static ActionKeybind TOGGLE_FPS_CHARTS = createActionKeybind("key.debug_actions.toggle_fps_charts", 50);
public static ActionKeybind TOGGLE_NETWORK_CHARTS = createActionKeybind("key.debug_actions.toggle_network_charts", 51);
public static ActionKeybind RELOAD_CHUNKS = createActionKeybind("key.debug_actions.reload_chunks", 65);
public static ActionKeybind SHOW_HITBOXES = createActionKeybind("key.debug_actions.show_hitboxes", 66);
public static ActionKeybind COPY_LOCATION = createActionKeybind("key.debug_actions.copy_location", 67);
Expand All @@ -34,6 +37,13 @@ public class DebugKeybinds {
public static ActionKeybind RELOAD_RESOURCEPACKS = createActionKeybind("key.debug_actions.reload_resourcepacks", 84);
public static ActionKeybind OPEN_GAMEMODE_SWITCHER = createActionKeybind("key.debug_actions.open_gamemode_switcher", 293);
public static ActionKeybind PAUSE_WITHOUT_MENU = createActionKeybind("key.debug_actions.pause_without_menu", 256);
public static ActionKeybind CHUNK_SECTION_PATH = createActionKeybind("key.debug_actions.chunk_section_path", 69);
public static ActionKeybind TOGGLE_FOG = createActionKeybind("key.debug_actions.toggle_fog", 70);
public static ActionKeybind TOGGLE_SMART_CULL = createActionKeybind("key.debug_actions.toggle_smart_cull", 76);
public static ActionKeybind TOGGLE_FRUSTUM_OCTREE = createActionKeybind("key.debug_actions.toggle_frustum_octree", 79);
public static ActionKeybind CAPTURE_FRUSTUM = createActionKeybind("key.debug_actions.capture_frustum", 85);
public static ActionKeybind TOGGLE_SECTION_VISIBILITY = createActionKeybind("key.debug_actions.toggle_section_visibility", 86);
public static ActionKeybind TOGGLE_WIREFRAME = createActionKeybind("key.debug_actions.toggle_wireframe", 87);

public static void refreshActionBindings() {
map.clear();
Expand Down Expand Up @@ -76,6 +86,9 @@ public static List<DebugKeybind> getGlobalKeybinds() {

public static List<DebugKeybind> getActionKeybinds() {
return Lists.newArrayList(
TOGGLE_PROFILER_CHART,
TOGGLE_FPS_CHARTS,
TOGGLE_NETWORK_CHARTS,
RELOAD_CHUNKS,
SHOW_HITBOXES,
COPY_LOCATION,
Expand All @@ -90,7 +103,14 @@ public static List<DebugKeybind> getActionKeybinds() {
DUMP_DYNAMIC_TEXTURES,
RELOAD_RESOURCEPACKS,
OPEN_GAMEMODE_SWITCHER,
PAUSE_WITHOUT_MENU
PAUSE_WITHOUT_MENU,
CHUNK_SECTION_PATH,
TOGGLE_FOG,
TOGGLE_SMART_CULL,
TOGGLE_FRUSTUM_OCTREE,
CAPTURE_FRUSTUM,
TOGGLE_SECTION_VISIBILITY,
TOGGLE_WIREFRAME
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ InputConstants.Key toKey(int k) {
public int hideGui = getDefault(HIDE_GUI);

// debug actions
public int toggleProfilerChart = getDefault(TOGGLE_PROFILER_CHART);
public int toggleFpsCharts = getDefault(TOGGLE_FPS_CHARTS);
public int toggleNetworkCharts = getDefault(TOGGLE_NETWORK_CHARTS);
public int reloadChunks = getDefault(RELOAD_CHUNKS);
public int showHitboxes = getDefault(SHOW_HITBOXES);
public int copyLocation = getDefault(COPY_LOCATION);
Expand All @@ -42,12 +45,22 @@ InputConstants.Key toKey(int k) {
public int reloadResourcePacks = getDefault(RELOAD_RESOURCEPACKS);
public int openGamemodeSwitcher = getDefault(OPEN_GAMEMODE_SWITCHER);
public int pauseWithoutMenu = getDefault(PAUSE_WITHOUT_MENU);
public int chunkSectionPath = getDefault(CHUNK_SECTION_PATH);
public int toggleFog = getDefault(TOGGLE_FOG);
public int toggleSmartCull = getDefault(TOGGLE_SMART_CULL);
public int toggleFrustumOctree = getDefault(TOGGLE_FRUSTUM_OCTREE);
public int captureFrustum = getDefault(CAPTURE_FRUSTUM);
public int toggleSectionVisibility = getDefault(TOGGLE_SECTION_VISIBILITY);
public int toggleWireframe = getDefault(TOGGLE_WIREFRAME);

@Override
public void onConfigLoadPost() {
DEBUG.setKey(toKey(debug));
HIDE_GUI.setKey(toKey(hideGui));

TOGGLE_PROFILER_CHART.setKey(toKey(toggleProfilerChart));
TOGGLE_FPS_CHARTS.setKey(toKey(toggleFpsCharts));
TOGGLE_NETWORK_CHARTS.setKey(toKey(toggleNetworkCharts));
RELOAD_CHUNKS.setKey(toKey(reloadChunks));
SHOW_HITBOXES.setKey(toKey(showHitboxes));
COPY_LOCATION.setKey(toKey(copyLocation));
Expand All @@ -63,6 +76,13 @@ public void onConfigLoadPost() {
RELOAD_RESOURCEPACKS.setKey(toKey(reloadResourcePacks));
OPEN_GAMEMODE_SWITCHER.setKey(toKey(openGamemodeSwitcher));
PAUSE_WITHOUT_MENU.setKey(toKey(pauseWithoutMenu));
CHUNK_SECTION_PATH.setKey(toKey(chunkSectionPath));
TOGGLE_FOG.setKey(toKey(toggleFog));
TOGGLE_SMART_CULL.setKey(toKey(toggleSmartCull));
TOGGLE_FRUSTUM_OCTREE.setKey(toKey(toggleFrustumOctree));
CAPTURE_FRUSTUM.setKey(toKey(captureFrustum));
TOGGLE_SECTION_VISIBILITY.setKey(toKey(toggleSectionVisibility));
TOGGLE_WIREFRAME.setKey(toKey(toggleWireframe));

DebugKeybinds.refreshActionBindings();

Expand All @@ -74,6 +94,9 @@ public void onConfigSavePre() {
debug = getKey(DEBUG);
hideGui = getKey(HIDE_GUI);

toggleProfilerChart = getKey(TOGGLE_PROFILER_CHART);
toggleFpsCharts = getKey(TOGGLE_FPS_CHARTS);
toggleNetworkCharts = getKey(TOGGLE_NETWORK_CHARTS);
reloadChunks = getKey(RELOAD_CHUNKS);
showHitboxes = getKey(SHOW_HITBOXES);
copyLocation = getKey(COPY_LOCATION);
Expand All @@ -89,6 +112,13 @@ public void onConfigSavePre() {
reloadResourcePacks = getKey(RELOAD_RESOURCEPACKS);
openGamemodeSwitcher = getKey(OPEN_GAMEMODE_SWITCHER);
pauseWithoutMenu = getKey(PAUSE_WITHOUT_MENU);
chunkSectionPath = getKey(CHUNK_SECTION_PATH);
toggleFog = getKey(TOGGLE_FOG);
toggleSmartCull = getKey(TOGGLE_SMART_CULL);
toggleFrustumOctree = getKey(TOGGLE_FRUSTUM_OCTREE);
captureFrustum = getKey(CAPTURE_FRUSTUM);
toggleSectionVisibility = getKey(TOGGLE_SECTION_VISIBILITY);
toggleWireframe = getKey(TOGGLE_WIREFRAME);

DebugKeybinds.refreshActionBindings();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public abstract class KeyboardHandlerMixin {

@Shadow protected abstract void debugFeedbackTranslated(String string, Object... objects);

@Shadow protected abstract boolean handleChunkDebugKeys(int i);

@ModifyConstant(
method = "keyPress",
constant = @Constant(intValue = 292)
Expand Down Expand Up @@ -70,29 +72,43 @@ private int remapDebugKeys(int i) {
at = @At("HEAD"),
cancellable = true
)
private void overrideHelpMenu(int i, CallbackInfoReturnable<Boolean> cir) {
if (!(this.debugCrashKeyTime > 0L && this.debugCrashKeyTime < Util.getMillis() - 100L) && i == 81) {
this.debugFeedbackTranslated("debug.help.message");

GlobalKeybind debugKey = DebugKeybinds.DEBUG;

ChatComponent chatComponent = this.minecraft.gui.getChat();
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.reload_chunks.help", debugKey, DebugKeybinds.RELOAD_CHUNKS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.show_hitboxes.help", debugKey, DebugKeybinds.SHOW_HITBOXES));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.copy_location.help", debugKey, DebugKeybinds.COPY_LOCATION));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.clear_chat.help", debugKey, DebugKeybinds.CLEAR_CHAT));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.chunk_boundaries.help", debugKey, DebugKeybinds.CHUNK_BORDERS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.advanced_tooltips.help", debugKey, DebugKeybinds.ADVANCED_TOOLTIPS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.inspect.help", debugKey, DebugKeybinds.INSPECT));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.profiling.help", debugKey, DebugKeybinds.PROFILING));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.creative_spectator.help", debugKey, DebugKeybinds.CREATIVE_SPECTATOR));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.pause_focus.help", debugKey, DebugKeybinds.PAUSE_FOCUS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.help.help", debugKey, DebugKeybinds.HELP));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.dump_dynamic_textures.help", debugKey, DebugKeybinds.DUMP_DYNAMIC_TEXTURES));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.reload_resourcepacks.help", debugKey, DebugKeybinds.RELOAD_RESOURCEPACKS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.pause.help", debugKey, DebugKeybinds.PAUSE_WITHOUT_MENU));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.gamemodes.help", debugKey, DebugKeybinds.OPEN_GAMEMODE_SWITCHER));
cir.setReturnValue(true);
private void overrideHelpMenuAndAddChunkKeys(int i, CallbackInfoReturnable<Boolean> cir) {
if (!(this.debugCrashKeyTime > 0L && this.debugCrashKeyTime < Util.getMillis() - 100L)) {
if (i == 81) {
this.debugFeedbackTranslated("debug.help.message");

GlobalKeybind debugKey = DebugKeybinds.DEBUG;

ChatComponent chatComponent = this.minecraft.gui.getChat();
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.reload_chunks.help", debugKey, DebugKeybinds.RELOAD_CHUNKS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.show_hitboxes.help", debugKey, DebugKeybinds.SHOW_HITBOXES));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.copy_location.help", debugKey, DebugKeybinds.COPY_LOCATION));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.clear_chat.help", debugKey, DebugKeybinds.CLEAR_CHAT));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.chunk_boundaries.help", debugKey, DebugKeybinds.CHUNK_BORDERS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.advanced_tooltips.help", debugKey, DebugKeybinds.ADVANCED_TOOLTIPS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.inspect.help", debugKey, DebugKeybinds.INSPECT));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.profiling.help", debugKey, DebugKeybinds.PROFILING));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.creative_spectator.help", debugKey, DebugKeybinds.CREATIVE_SPECTATOR));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.pause_focus.help", debugKey, DebugKeybinds.PAUSE_FOCUS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.help.help", debugKey, DebugKeybinds.HELP));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.dump_dynamic_textures.help", debugKey, DebugKeybinds.DUMP_DYNAMIC_TEXTURES));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.reload_resourcepacks.help", debugKey, DebugKeybinds.RELOAD_RESOURCEPACKS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.pause.help", debugKey, DebugKeybinds.PAUSE_WITHOUT_MENU));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.gamemodes.help", debugKey, DebugKeybinds.OPEN_GAMEMODE_SWITCHER));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_profiler_chart.help", debugKey, DebugKeybinds.TOGGLE_PROFILER_CHART));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_fps_charts.help", debugKey, DebugKeybinds.TOGGLE_FPS_CHARTS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_network_charts.help", debugKey, DebugKeybinds.TOGGLE_NETWORK_CHARTS));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_fog.help", debugKey, DebugKeybinds.TOGGLE_FOG));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_smart_cull.help", debugKey, DebugKeybinds.TOGGLE_SMART_CULL));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_frustum_octree.help", debugKey, DebugKeybinds.TOGGLE_FRUSTUM_OCTREE));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.capture_frustum.help", debugKey, DebugKeybinds.CAPTURE_FRUSTUM));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_section_visibility.help", debugKey, DebugKeybinds.TOGGLE_SECTION_VISIBILITY));
chatComponent.addMessage(debugKeybind$translateHelpMessage("debug.toggle_wireframe.help", debugKey, DebugKeybinds.TOGGLE_WIREFRAME));
cir.setReturnValue(true);
} else {
boolean bl = handleChunkDebugKeys(i);
if (bl) cir.setReturnValue(true);
}
}
}

Expand Down
22 changes: 21 additions & 1 deletion common/src/main/resources/assets/debugkeybind/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"key.debug.debugkeybind": "Debug Key",
"key.debug.hide_gui": "Hide GUI",

"key.debug_actions.toggle_profiler_chart": "Toggle Profiler Chart",
"key.debug_actions.toggle_fps_charts": "Toggle FPS Charts",
"key.debug_actions.toggle_network_charts": "Toggle Network Charts",
"key.debug_actions.reload_chunks": "Reload All Chunks",
"key.debug_actions.show_hitboxes": "Show Hitboxes",
"key.debug_actions.copy_location": "Copy Location (hold to crash game)",
Expand All @@ -24,5 +27,22 @@
"key.debug_actions.dynamic_textures": "Dump Dynamic Textures",
"key.debug_actions.reload_resourcepacks": "Reload All Resource Packs",
"key.debug_actions.open_gamemode_switcher": "Open Gamemode Switcher",
"key.debug_actions.pause_without_menu": "Pause Without Pause Menu (if possible)"
"key.debug_actions.pause_without_menu": "Pause Without Pause Menu (if possible)",
"key.debug_actions.chunk_section_path": "Chunk Section Path",
"key.debug_actions.toggle_fog": "Toggle Fog",
"key.debug_actions.toggle_smart_cull": "Toggle Smart Cull",
"key.debug_actions.toggle_frustum_octree": "Toggle Frustum Octree",
"key.debug_actions.capture_frustum": "Capture Frustum",
"key.debug_actions.toggle_section_visibility": "Toggle Section Visibility",
"key.debug_actions.toggle_wireframe": "Toggle Wireframe",

"debug.toggle_profiler_chart.help": "F3 + 1 = Toggle Profiler Chart",
"debug.toggle_fps_charts.help": "F3 + 2 = Toggle FPS Charts",
"debug.toggle_network_charts.help": "F3 + 3 = Toggle Network Charts",
"debug.toggle_fog.help": "F3 + F = Toggle Fog",
"debug.toggle_smart_cull.help": "F3 + L = Toggle Smart Cull",
"debug.toggle_frustum_octree.help": "F3 + O = Toggle Frustum Octree",
"debug.capture_frustum.help": "F3 + U = Capture Frustum (shift to kill)",
"debug.toggle_section_visibility.help": "F3 + V = Toggle Section Visibility",
"debug.toggle_wireframe.help": "F3 + W = Toggle Wireframe"
}
Loading

0 comments on commit a609507

Please sign in to comment.