Skip to content

Commit

Permalink
Bug fixing (On trial)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Sep 20, 2023
1 parent c5cff96 commit dd31a7d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/tanishisherewith/dynamichud/DynamicHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.tanishisherewith.dynamichud.huds.AbstractMoveableScreen;
import com.tanishisherewith.dynamichud.interfaces.IWigdets;
import com.tanishisherewith.dynamichud.util.DynamicUtil;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
Expand All @@ -21,7 +21,7 @@

import java.io.File;

public class DynamicHUD implements ClientModInitializer {
public class DynamicHUD implements ModInitializer {

private static final Logger logger = LoggerFactory.getLogger("DynamicHud");
static AbstractMoveableScreen Screen;
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void printWarn(String msg) {
}

@Override
public void onInitializeClient() {
public void onInitialize() {
dynamicutil = new DynamicUtil(mc);
printInfo("DynamicHud Initialised");

Expand Down
32 changes: 16 additions & 16 deletions src/main/java/com/tanishisherewith/dynamichud/DynamicHUDmod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import com.tanishisherewith.dynamichud.widget.armor.ArmorWidget;
import com.tanishisherewith.dynamichud.widget.item.ItemWidget;
import com.tanishisherewith.dynamichud.widget.text.TextWidget;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.Items;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;

Expand Down Expand Up @@ -54,15 +54,15 @@ public void addWigdets(DynamicUtil dynamicUtil) {
}

private void addTextWidgets(DynamicUtil dynamicUtil) {
widgets.add(new TextWidget(mc, "FPS: ", () -> mc.fpsDebugString.split(" ")[0], 0.5f, 0.5f, true, true, -1, -1, true));
widgets.add(new TextWidget(mc, "Non Draggable FPS: ", () -> mc.fpsDebugString.split(" ")[0], 0.5f, 0.5f, true, true, -1, -1, true));
widgets.add(new TextWidget(mc, "Dynamic", () -> "HUD", 0.7f, 0.3f, false, false, -1, -1, true));
widgets.add(new TextWidget(mc, "Ping: ", () -> "", 0.08f, 0.5f, false, false, -1, -1, true));
widgets.add(new TextWidget(mc, "Position: ", () -> "", 0.4f, 0.8f, false, false, -1, -1, true));
widgets.add(new TextWidget(mc, "Day/Night: ", () -> "", 0.83f, 0.8f, false, false, -1, -1, true));
widgets.add(new TextWidget(mc, "Test", () -> "", 0.08f, 0.5f, false, false, -1, -1, true));
widgets.add(new TextWidget(mc, "", () -> "Data Test", 0.4f, 0.8f, false, false, -1, -1, true));
widgets.add(new TextWidget(mc, "HUD Test ", () -> "", 0.83f, 0.8f, false, false, -1, -1, true));

for (Widget widget : widgets) {
if (widget instanceof TextWidget textWidget) {
if (textWidget.getText().equalsIgnoreCase("fps: ")) {
if (textWidget.getText().equalsIgnoreCase("Non Draggable FPS: ")) {
textWidget.setDraggable(false);
}
}
Expand Down Expand Up @@ -120,12 +120,12 @@ private void addItemWidgets(DynamicUtil dynamicUtil) {
public void addMainMenuWigdets(DynamicUtil dynamicUtil) {
printInfo("MainMenu Widgets added");

MainMenuwidgets.add(new TextWidget(mc, "Day/NightS: ", () -> "", 0.83f, 0.8f, false, false, -1, -1, true));
MainMenuwidgets.add(new TextWidget(mc, "FpsE: ", () -> "", 0.85f, 0.3f, false, false, -1, -1, true));
MainMenuwidgets.add(new TextWidget(mc, "Test: ", () -> "", 0.87f, 0.5f, false, false, -1, -1, true));
MainMenuwidgets.add(new TextWidget(mc, "Test ", () -> "", 0.83f, 0.8f, false, false, -1, -1, true));
MainMenuwidgets.add(new TextWidget(mc, "E Test ", () -> "", 0.85f, 0.3f, false, false, -1, -1, true));
MainMenuwidgets.add(new TextWidget(mc, "Non Draggable FPS: ", () -> String.valueOf(mc.getCurrentFps()), 0.67f, 0.5f, false, false, -1, -1, true));
for (Widget mmwigdet : MainMenuwidgets) {
if (mmwigdet instanceof TextWidget textWidget) {
if (textWidget.getText().equalsIgnoreCase("fps: ")) {
if (textWidget.getText().equalsIgnoreCase("Non Draggable FPS: ")) {
textWidget.setDraggable(false);
}
}
Expand All @@ -139,14 +139,14 @@ public void loadWigdets(DynamicUtil dynamicUtil) {
Set<Widget> widgets = dynamicUtil.getWidgetManager().loadWigdets(WIDGETS_FILE);
Set<Widget> MainMenuWidget = dynamicUtil.getWidgetManager().loadMainMenuWigdets(WIDGETS_FILE);

Widget.addTextGenerator("FPS: ", () -> String.valueOf(mc.getCurrentFps()));
Widget.addTextGenerator("Non Draggable FPS: ", () -> String.valueOf(mc.getCurrentFps()));
Widget.addTextGenerator("Dynamic", () -> "HUD");
Widget.addTextGenerator("Ping: ", () -> "");
Widget.addTextGenerator("Position: ", () -> "");
Widget.addTextGenerator("Day/Night: ", () -> "");
Widget.addTextGenerator("Test", () -> "");
Widget.addTextGenerator("", () -> "Data Test");
Widget.addTextGenerator("HUD Test ", () -> "");
Widget.addTextGenerator("Text", () -> "Text");
Widget.addTextGenerator("FPS", () -> String.valueOf(mc.getCurrentFps()));
Widget.addTextGenerator("FpsE:", () -> String.valueOf(mc.getCurrentFps()));
Widget.addTextGenerator("Test ", () -> String.valueOf(mc.getCurrentFps()));
Widget.addTextGenerator("Non Draggable FPS: ", () -> String.valueOf(mc.getCurrentFps()));
Widget.addTextGenerator("Label", () -> "Label");

for (Widget widget : widgets) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.tanishisherewith.dynamichud.widget;

import com.mojang.serialization.Decoder;
import com.tanishisherewith.dynamichud.interfaces.TextGenerator;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.nbt.NbtCompound;

import java.awt.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.*;

/**
* This class represents a widget that can be displayed on the screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.tanishisherewith.dynamichud.DynamicHUD;
import com.tanishisherewith.dynamichud.interfaces.WidgetLoading;
import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtList;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"license": "All-Rights-Reserved",
"environment": "client",
"entrypoints": {
"client": [
"mod": [
"com.tanishisherewith.dynamichud.DynamicHUD"
],
"modmenu": [
Expand Down

0 comments on commit dd31a7d

Please sign in to comment.