aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java3
-rw-r--r--src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java38
-rw-r--r--src/main/java/de/hysky/skyblocker/config/categories/DebugCategory.java39
-rw-r--r--src/main/java/de/hysky/skyblocker/config/configs/DebugConfig.java14
-rw-r--r--src/main/java/de/hysky/skyblocker/debug/Debug.java92
-rw-r--r--src/main/java/de/hysky/skyblocker/mixins/EntityMixin.java29
-rw-r--r--src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java4
-rw-r--r--src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java18
8 files changed, 163 insertions, 74 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
index c9246599..eed0eba9 100644
--- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
@@ -48,4 +48,7 @@ public class SkyblockerConfig {
@SerialEntry
public MiscConfig misc = new MiscConfig();
+
+ @SerialEntry
+ public DebugConfig debug = new DebugConfig();
}
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java
index f519473c..5288d247 100644
--- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java
+++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java
@@ -4,6 +4,7 @@ import com.google.gson.FieldNamingPolicy;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.categories.*;
+import de.hysky.skyblocker.debug.Debug;
import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor;
import de.hysky.skyblocker.utils.scheduler.Scheduler;
import dev.isxander.yacl3.api.YetAnotherConfigLib;
@@ -69,22 +70,27 @@ public class SkyblockerConfigManager {
}
public static Screen createGUI(Screen parent) {
- return YetAnotherConfigLib.create(HANDLER, (defaults, config, builder) -> builder
- .title(Text.translatable("skyblocker.config.title"))
- .category(GeneralCategory.create(defaults, config))
- .category(UIAndVisualsCategory.create(defaults, config))
- .category(HelperCategory.create(defaults, config))
- .category(DungeonsCategory.create(defaults, config))
- //.category(ForagingCategory.create(defaults, config))
- .category(CrimsonIsleCategory.create(defaults, config))
- .category(MiningCategory.create(defaults, config))
- .category(FarmingCategory.create(defaults, config))
- .category(OtherLocationsCategory.create(defaults, config))
- .category(SlayersCategory.create(defaults, config))
- .category(ChatCategory.create(defaults, config))
- .category(QuickNavigationCategory.create(defaults, config))
- .category(EventNotificationsCategory.create(defaults, config))
- .category(MiscCategory.create(defaults, config))).generateScreen(parent);
+ return YetAnotherConfigLib.create(HANDLER, (defaults, config, builder) -> {
+ builder.title(Text.translatable("skyblocker.config.title"))
+ .category(GeneralCategory.create(defaults, config))
+ .category(UIAndVisualsCategory.create(defaults, config))
+ .category(HelperCategory.create(defaults, config))
+ .category(DungeonsCategory.create(defaults, config))
+ //.category(ForagingCategory.create(defaults, config))
+ .category(CrimsonIsleCategory.create(defaults, config))
+ .category(MiningCategory.create(defaults, config))
+ .category(FarmingCategory.create(defaults, config))
+ .category(OtherLocationsCategory.create(defaults, config))
+ .category(SlayersCategory.create(defaults, config))
+ .category(ChatCategory.create(defaults, config))
+ .category(QuickNavigationCategory.create(defaults, config))
+ .category(EventNotificationsCategory.create(defaults, config))
+ .category(MiscCategory.create(defaults, config));
+ if (Debug.debugEnabled()) {
+ builder.category(DebugCategory.create(defaults, config));
+ }
+ return builder;
+ }).generateScreen(parent);
}
/**
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DebugCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DebugCategory.java
new file mode 100644
index 00000000..b07753a5
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/config/categories/DebugCategory.java
@@ -0,0 +1,39 @@
+package de.hysky.skyblocker.config.categories;
+
+import de.hysky.skyblocker.config.ConfigUtils;
+import de.hysky.skyblocker.config.SkyblockerConfig;
+import dev.isxander.yacl3.api.ConfigCategory;
+import dev.isxander.yacl3.api.Option;
+import dev.isxander.yacl3.api.OptionDescription;
+import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
+import net.minecraft.text.Text;
+
+public class DebugCategory {
+ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) {
+ return ConfigCategory.createBuilder()
+ .name(Text.translatable("skyblocker.config.debug"))
+ .option(Option.<Integer>createBuilder()
+ .name(Text.translatable("skyblocker.config.debug.dumpRange"))
+ .description(OptionDescription.of(Text.translatable("skyblocker.config.debug.dumpRange.@Tooltip")))
+ .binding(defaults.debug.dumpRange,
+ () -> config.debug.dumpRange,
+ newValue -> config.debug.dumpRange = newValue)
+ .controller(option -> IntegerSliderControllerBuilder.create(option).range(1, 25).step(1))
+ .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.debug.showInvisibleArmorStands"))
+ .binding(defaults.debug.showInvisibleArmorStands,
+ () -> config.debug.showInvisibleArmorStands,
+ newValue -> config.debug.showInvisibleArmorStands = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.debug.debugWebSockets"))
+ .binding(defaults.debug.webSocketDebug,
+ () -> config.debug.webSocketDebug,
+ newValue -> config.debug.webSocketDebug = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .build();
+ }
+}
diff --git a/src/main/java/de/hysky/skyblocker/config/configs/DebugConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/DebugConfig.java
new file mode 100644
index 00000000..16474a49
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/config/configs/DebugConfig.java
@@ -0,0 +1,14 @@
+package de.hysky.skyblocker.config.configs;
+
+import dev.isxander.yacl3.config.v2.api.SerialEntry;
+
+public class DebugConfig {
+ @SerialEntry
+ public int dumpRange = 5;
+
+ @SerialEntry
+ public boolean showInvisibleArmorStands = false;
+
+ @SerialEntry
+ public boolean webSocketDebug = false;
+}
diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java
index 19d06579..7805c4e4 100644
--- a/src/main/java/de/hysky/skyblocker/debug/Debug.java
+++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java
@@ -5,6 +5,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.serialization.JsonOps;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.annotations.Init;
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
@@ -13,13 +14,18 @@ import de.hysky.skyblocker.utils.networth.NetworthCalculator;
import net.azureaaron.networth.Calculation;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
+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.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.option.KeyBinding;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.nbt.NbtHelper;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
@@ -31,49 +37,59 @@ import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.lit
public class Debug {
private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false"));
-
- private static boolean showInvisibleArmorStands = false;
- private static boolean webSocketDebug = false;
+ //This is necessary to not spam the chat with 20 messages per second
+ private static boolean keyDown = false;
public static boolean debugEnabled() {
return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment();
}
- public static boolean shouldShowInvisibleArmorStands() {
- return showInvisibleArmorStands;
- }
-
public static boolean webSocketDebug() {
- return webSocketDebug;
+ return SkyblockerConfigManager.get().debug.webSocketDebug;
}
@Init
public static void init() {
- if (debugEnabled()) {
- SnapshotDebug.init();
- ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug")
- .then(dumpPlayersCommand())
- .then(ItemUtils.dumpHeldItemCommand())
- .then(ItemUtils.dumpHeldItemNetworthCalculationsCommand())
- .then(toggleShowingInvisibleArmorStands())
- .then(dumpArmorStandHeadTextures())
- .then(toggleWebSocketDebug())
- )));
- ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
- if (screen instanceof HandledScreen<?> handledScreen) {
- ScreenKeyboardEvents.afterKeyPress(screen).register((_screen, key, scancode, modifier) -> {
- Slot focusedSlot = ((HandledScreenAccessor) handledScreen).getFocusedSlot();
- if (key == GLFW.GLFW_KEY_U && client.player != null && focusedSlot != null && focusedSlot.hasStack()) {
- if (!Screen.hasShiftDown()) {
- client.player.sendMessage(Text.literal("[Skyblocker Debug] Hovered Item: " + SkyblockerMod.GSON_COMPACT.toJson(ItemStack.CODEC.encodeStart(ItemStackComponentizationFixer.getRegistryLookup().getOps(JsonOps.INSTANCE), focusedSlot.getStack()).getOrThrow())));
- } else {
- client.player.sendMessage(Text.literal("[Skyblocker Debug] Held Item NW Calcs: " + SkyblockerMod.GSON_COMPACT.toJson(Calculation.LIST_CODEC.encodeStart(JsonOps.INSTANCE, NetworthCalculator.getItemNetworth(focusedSlot.getStack()).calculations()).getOrThrow())));
- }
- }
- });
+ if (!debugEnabled()) return;
+ SnapshotDebug.init();
+ KeyBinding dumpNearbyEntitiesKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.skyblocker.debug.dumpNearbyEntities", GLFW.GLFW_KEY_I, "key.categories.skyblocker"));
+ KeyBinding dumpHoveredItemKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.skyblocker.debug.dumpHoveredItem", GLFW.GLFW_KEY_U, "key.categories.skyblocker"));
+ ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(
+ literal(SkyblockerMod.NAMESPACE).then(literal("debug")
+ .then(dumpPlayersCommand())
+ .then(ItemUtils.dumpHeldItemCommand())
+ .then(ItemUtils.dumpHeldItemNetworthCalculationsCommand())
+ .then(toggleShowingInvisibleArmorStands())
+ .then(dumpArmorStandHeadTextures())
+ .then(toggleWebSocketDebug())
+ )
+ ));
+ ClientTickEvents.END_CLIENT_TICK.register(client -> {
+ if (client.player == null || client.world == null) return;
+ if (dumpNearbyEntitiesKey.wasPressed() && !keyDown) {
+ client.world.getOtherEntities(client.player, client.player.getBoundingBox().expand(SkyblockerConfigManager.get().debug.dumpRange))
+ .stream()
+ .map(entity -> entity.writeNbt(new NbtCompound()))
+ .map(NbtHelper::toPrettyPrintedText)
+ .forEach(client.player::sendMessage);
+ keyDown = true;
+ } else if (!dumpNearbyEntitiesKey.wasPressed() && keyDown) {
+ keyDown = false;
+ }
+ });
+ ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
+ if (!(screen instanceof HandledScreen<?> handledScreen)) return;
+ ScreenKeyboardEvents.afterKeyPress(screen).register((_screen, key, scancode, modifier) -> {
+ Slot focusedSlot = ((HandledScreenAccessor) handledScreen).getFocusedSlot();
+ if (dumpHoveredItemKey.matchesKey(key, scancode) && client.player != null && focusedSlot != null && focusedSlot.hasStack()) {
+ if (!Screen.hasShiftDown()) {
+ client.player.sendMessage(Constants.PREFIX.get().append(Text.literal("Hovered Item: " + SkyblockerMod.GSON_COMPACT.toJson(ItemStack.CODEC.encodeStart(ItemStackComponentizationFixer.getRegistryLookup().getOps(JsonOps.INSTANCE), focusedSlot.getStack()).getOrThrow()))));
+ } else {
+ client.player.sendMessage(Constants.PREFIX.get().append(Text.literal("Held Item NW Calcs: " + SkyblockerMod.GSON_COMPACT.toJson(Calculation.LIST_CODEC.encodeStart(JsonOps.INSTANCE, NetworthCalculator.getItemNetworth(focusedSlot.getStack()).calculations()).getOrThrow()))));
+ }
}
});
- }
+ });
}
private static LiteralArgumentBuilder<FabricClientCommandSource> dumpPlayersCommand() {
@@ -87,8 +103,9 @@ public class Debug {
private static LiteralArgumentBuilder<FabricClientCommandSource> toggleShowingInvisibleArmorStands() {
return literal("toggleShowingInvisibleArmorStands")
.executes(context -> {
- showInvisibleArmorStands = !showInvisibleArmorStands;
- context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.debug.toggledShowingInvisibleArmorStands", showInvisibleArmorStands)));
+ SkyblockerConfigManager.get().debug.showInvisibleArmorStands = !SkyblockerConfigManager.get().debug.showInvisibleArmorStands;
+ SkyblockerConfigManager.save();
+ context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.debug.toggledShowingInvisibleArmorStands", SkyblockerConfigManager.get().debug.showInvisibleArmorStands)));
return Command.SINGLE_SUCCESS;
});
}
@@ -96,12 +113,13 @@ public class Debug {
private static LiteralArgumentBuilder<FabricClientCommandSource> toggleWebSocketDebug() {
return literal("toggleWebSocketDebug")
.executes(context -> {
- webSocketDebug = !webSocketDebug;
- context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.debug.toggledWebSocketDebug", webSocketDebug)));
+ SkyblockerConfigManager.get().debug.webSocketDebug = !SkyblockerConfigManager.get().debug.webSocketDebug;
+ SkyblockerConfigManager.save();
+ context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.debug.toggledWebSocketDebug", SkyblockerConfigManager.get().debug.webSocketDebug)));
return Command.SINGLE_SUCCESS;
});
}
-
+
private static LiteralArgumentBuilder<FabricClientCommandSource> dumpArmorStandHeadTextures() {
return literal("dumpArmorStandHeadTextures")
.executes(context -> {
@@ -118,4 +136,4 @@ public class Debug {
return Command.SINGLE_SUCCESS;
});
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/de/hysky/skyblocker/mixins/EntityMixin.java b/src/main/java/de/hysky/skyblocker/mixins/EntityMixin.java
new file mode 100644
index 00000000..9f8701c1
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/mixins/EntityMixin.java
@@ -0,0 +1,29 @@
+package de.hysky.skyblocker.mixins;
+
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import de.hysky.skyblocker.debug.Debug;
+import de.hysky.skyblocker.utils.Utils;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.player.PlayerEntity;
+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(Entity.class)
+public abstract class EntityMixin {
+ @Shadow
+ @Final
+ private EntityType<?> type;
+
+ @Shadow
+ public abstract boolean isInvisible();
+
+ @Inject(method = "isInvisibleTo", at = @At("HEAD"), cancellable = true)
+ public void skyblocker$showInvisibleArmorStands(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
+ if (isInvisible() && Utils.isOnHypixel() && Debug.debugEnabled() && SkyblockerConfigManager.get().debug.showInvisibleArmorStands && type.equals(EntityType.ARMOR_STAND)) cir.setReturnValue(false);
+ }
+}
diff --git a/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java b/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java
index c03a3a55..cc7b8119 100644
--- a/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java
+++ b/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java
@@ -3,7 +3,6 @@ package de.hysky.skyblocker.mixins;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
-
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.debug.Debug;
import de.hysky.skyblocker.utils.ItemUtils;
@@ -12,7 +11,6 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.decoration.ArmorStandEntity;
-
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -29,6 +27,6 @@ public class EntityRenderDispatcherMixin {
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isInvisible()Z", ordinal = 1))
private <E extends Entity> boolean skyblocker$armorStandHitboxVisible(boolean invisible, E entity) {
- return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled() || !Debug.shouldShowInvisibleArmorStands()) && invisible;
+ return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled() || !SkyblockerConfigManager.get().debug.showInvisibleArmorStands) && invisible;
}
}
diff --git a/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java b/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java
deleted file mode 100644
index 60fa7dec..00000000
--- a/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.hysky.skyblocker.mixins;
-
-import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
-import de.hysky.skyblocker.debug.Debug;
-import de.hysky.skyblocker.utils.Utils;
-import net.minecraft.client.render.entity.LivingEntityRenderer;
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.entity.decoration.ArmorStandEntity;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-
-@Mixin(LivingEntityRenderer.class)
-public class LivingEntityRendererMixin {
- @ModifyExpressionValue(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;isVisible(Lnet/minecraft/entity/LivingEntity;)Z"))
- private <T extends LivingEntity> boolean skyblocker$armorStandVisible(boolean visible, T entity) {
- return entity instanceof ArmorStandEntity && Utils.isOnHypixel() && Debug.debugEnabled() && Debug.shouldShowInvisibleArmorStands() || visible;
- }
-}