Skip to content

Commit

Permalink
Port to 1.19.4 (not sure if it works)
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Jul 13, 2023
1 parent b6f88cd commit b30357e
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
import com.ultreon.mods.advanceddebug.extension.ExtensionLoader;
import com.ultreon.mods.advanceddebug.init.ModDebugPages;
import com.ultreon.mods.advanceddebug.init.ModOverlays;
import dev.architectury.event.EventResult;
import dev.architectury.event.events.client.ClientLifecycleEvent;
import dev.architectury.event.events.client.ClientRawInputEvent;
import dev.architectury.event.events.client.ClientTickEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
Expand All @@ -37,19 +36,16 @@ public AdvancedDebug() {
instance = this;
}

private static EventResult keyPressed(Minecraft client, int keyCode, int scanCode, int action, int modifiers) {
if (DebugGui.get().onKeyReleased(keyCode, scanCode, action, modifiers)) {
return EventResult.interruptTrue();
}
return EventResult.pass();
private static void tick(Minecraft minecraft) {
DebugGui.get().tick();
}

public void init() {
ModOverlays.registerAll();

ClientLifecycleEvent.CLIENT_SETUP.register(this::setup);

ClientRawInputEvent.KEY_PRESSED.register(AdvancedDebug::keyPressed);
ClientTickEvent.CLIENT_POST.register(AdvancedDebug::tick);

KeyBindingList.register();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import com.ultreon.mods.advanceddebug.client.input.KeyBindingList;
import com.ultreon.mods.advanceddebug.client.menu.pages.DefaultPage;
import com.ultreon.mods.advanceddebug.client.registry.FormatterRegistry;
import com.ultreon.mods.advanceddebug.mixin.common.KeyMappingAccessor;
import com.ultreon.mods.advanceddebug.text.ComponentBuilder;
import com.ultreon.mods.advanceddebug.util.InputUtils;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
Expand All @@ -25,7 +25,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

Expand Down Expand Up @@ -201,13 +200,11 @@ public void prev() {
setPage(getPage() - 1);
}

public boolean onKeyReleased(int keyCode, int scanCode, int action, int modifiers) {
if (action == GLFW.GLFW_RELEASE && keyCode == ((KeyMappingAccessor)KeyBindingList.DEBUG_SCREEN).getKey().getValue()) {
public void tick() {
if (KeyBindingList.DEBUG_SCREEN.consumeClick()) {
if (InputUtils.isShiftDown()) prev();
else next();
return true;
}
return false;
}

@Deprecated(forRemoval = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
package com.ultreon.mods.advanceddebug.client.menu.pages;

import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.Monitor;
import com.mojang.blaze3d.platform.VideoMode;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
import com.ultreon.mods.advanceddebug.api.client.menu.DebugPage;
import com.ultreon.mods.advanceddebug.api.client.menu.IDebugRenderContext;
import com.ultreon.mods.advanceddebug.api.common.IntSize;
import com.ultreon.mods.advanceddebug.mixin.common.WindowAccessor;
import net.minecraft.client.Minecraft;
import org.lwjgl.glfw.GLFW;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory;
import oshi.hardware.GraphicsCard;
import oshi.hardware.PhysicalMemory;

import java.util.Arrays;
import java.util.List;

public class ComputerPage extends DebugPage {
private final Minecraft mc = Minecraft.getInstance();
private final Window window = mc.getWindow();
private static final SystemInfo SYSTEM_INFO = new SystemInfo();

public ComputerPage(String modId, String name) {
super(modId, name);
}

@Override
public void render(PoseStack poseStack, IDebugRenderContext ctx) {
long l = GLFW.glfwGetWindowMonitor(window.getWindow());
Monitor monitor = ((WindowAccessor)(Object)window).getScreenManager().getMonitor(l);
long l = GLFW.glfwGetWindowMonitor(getWindow().getWindow());
Monitor monitor = ((WindowAccessor)(Object)getWindow()).getScreenManager().getMonitor(l);

if (monitor != null) {
VideoMode currentMode = monitor.getCurrentMode();
Expand Down Expand Up @@ -87,6 +93,25 @@ public void render(PoseStack poseStack, IDebugRenderContext ctx) {

}

ctx.right("Is Java 64-bit", (mc.is64Bit() ? "yes" : "no"));
ctx.right("System");
ctx.right("Is Java 64-bit", (minecraft.is64Bit() ? "yes" : "no"));
ctx.right("Platform", SystemInfo.getCurrentPlatform());

CentralProcessor processor = SYSTEM_INFO.getHardware().getProcessor();
ctx.right("Processor");
// ctx.right("CPU Frequencies", Arrays.stream(processor.getCurrentFreq()).boxed().toList());
ctx.right("CPU Max Frequency", Lists.newArrayList(processor.getMaxFreq()));
ctx.right("CPU Phys. Processor Count", processor.getPhysicalProcessorCount());
ctx.right("CPU Logic. Processor Count", processor.getLogicalProcessorCount());
ctx.right("CPU Interrupts", processor.getInterrupts());
ctx.right("CPU Load", processor.getProcessorCpuLoad(1000000000L));

GlobalMemory memory = SYSTEM_INFO.getHardware().getMemory();
ctx.right("Memory");
ctx.right("Physical Memory", memory.getPhysicalMemory().stream().mapToLong(PhysicalMemory::getCapacity).sum());
ctx.right("Virtual Memory", memory.getVirtualMemory().getVirtualMax());
ctx.right("Swap Memory", memory.getVirtualMemory().getSwapTotal());
ctx.right("Total Memory", memory.getTotal());
ctx.right("Memory Available", memory.getAvailable());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ public void render(PoseStack poseStack, IDebugRenderContext ctx) {
ctx.right("Armor Value", living.getArmorValue());
} else if (entity instanceof ItemEntity itemEntity) {
ctx.right(GRAY + "Item Entity");
ctx.right("Age", itemEntity.getAge());
ctx.right("Item", itemEntity.getItem());
ctx.right("Owner", itemEntity.getOwner());
ctx.right("Thrower", itemEntity.getThrower());
ctx.right("Pose", itemEntity.getPose());
ctx.right("Item", itemEntity.getItem());
ctx.right("Spin", itemEntity.getSpin(minecraft.getFrameTime()));
ctx.right("Age", itemEntity.getAge());
}
} else {
// not looking at a block, or too far away from one to tell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public void render(PoseStack poseStack, IDebugRenderContext ctx) {
EntityHitResult entityHit = TargetUtils.entity();
if (entityHit != null && entityHit.getEntity() instanceof ItemEntity entity) {
ctx.left("Generic");
ctx.left("Thrower", entity.getThrower());
ctx.left("Owner", entity.getOwner());
ctx.left("Item", entity.getItem());
ctx.left("Spin", entity.getSpin(minecraft.getFrameTime()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public void render(PoseStack poseStack, IDebugRenderContext ctx) {
ctx.left("Arrows", entity.getArrowCount());
ctx.left("Time Fall-flying", entity.getFallFlyingTicks());
ctx.left("Jump Boost Power", entity.getJumpBoostPower());
ctx.left("Mob Type", entity.getMobType());
ctx.left("Idle For", entity.getNoActionTime());
ctx.left("Scale", entity.getScale());
ctx.left("Speed", entity.getSpeed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void render(PoseStack poseStack, IDebugRenderContext ctx) {
ctx.right("Name", minecraft.name());
ctx.right("Pending Tasks", minecraft.getPendingTasksCount());
ctx.right("Open Screen", screen == null ? null : screen.getClass());
ctx.right("Language", minecraft.getGame().getSelectedLanguage().getCode());
ctx.right("Language", minecraft.getLanguageManager().getSelected());
ctx.right();

ctx.right("Flags");
Expand Down
6 changes: 3 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
],
"depends": {
"fabricloader": ">=${loaderVersion}",
"minecraft": ">=${minecraftVersion} <1.19.4",
"architectury": ">=7.1 <8.0",
"forgeconfigapiport": ">=5.0 <6.0"
"minecraft": ">=${minecraftVersion} <1.20",
"architectury": ">=8.1 <9.0",
"forgeconfigapiport": ">=6.0 <7.0"
}
}
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ side = "CLIENT"
[[dependencies.advanced_debug]]
modId = "minecraft"
mandatory = true
versionRange = "[${minecraftVersion},1.19.4)"
versionRange = "[${minecraftVersion},1.20)"
ordering = "NONE"
side = "CLIENT"
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
org.gradle.jvmargs=-Xmx5G
minecraft_version=1.19.3
minecraft_version=1.19.4
archives_base_name=advanced-debug
mod_version=2.1.1
mod_version=2.2.0
maven_group=com.ultreon.mods
architectury_version=7.1.78
architectury_version=8.1.80
fabric_loader_version=0.14.19
fabric_api_version=0.76.1+1.19.3
forge_version=44.1.23
fabric_api_version=0.81.1+1.19.4
forge_version=45.0.64

forge_config_api_port_version=5.0.3
modmenu_version=5.0.0
rei_version=10.0.596
forge_config_api_port_version=6.0.2
modmenu_version=6.2.2
rei_version=11.0.597

nightconfig_version=3.6.5

Expand Down

0 comments on commit b30357e

Please sign in to comment.