From c7088f48ef5b2f5a61f471d93ee23f4f2ccad010 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:09:42 -0400 Subject: [PATCH 1/2] Add dump held item nbt command --- .../de/hysky/skyblocker/SkyblockerMod.java | 4 +-- .../java/de/hysky/skyblocker/debug/Debug.java | 27 ++++++++++++++-- .../skyblocker/debug/DumpPlayersCommand.java | 31 ------------------- .../de/hysky/skyblocker/utils/ItemUtils.java | 12 +++++++ 4 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 1473d1dea3..ad5e442f85 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -5,7 +5,6 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.debug.Debug; import de.hysky.skyblocker.skyblock.*; -import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.skyblock.dungeon.*; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.skyblock.dungeon.secrets.SecretsTracker; @@ -18,11 +17,12 @@ import de.hysky.skyblocker.skyblock.rift.TheRift; import de.hysky.skyblocker.skyblock.shortcut.Shortcuts; import de.hysky.skyblocker.skyblock.special.SpecialEffects; -import de.hysky.skyblocker.skyblock.waypoint.Relics; import de.hysky.skyblocker.skyblock.tabhud.TabHud; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; import de.hysky.skyblocker.skyblock.waypoint.FairySouls; +import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; +import de.hysky.skyblocker.skyblock.waypoint.Relics; import de.hysky.skyblocker.utils.ApiUtils; import de.hysky.skyblocker.utils.NEURepoManager; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 1fc22d2a0d..86adcac652 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -1,14 +1,37 @@ package de.hysky.skyblocker.debug; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.utils.ItemUtils; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.text.Text; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; public class Debug { private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); + public static boolean debugEnabled() { + return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment(); + } + public static void init() { - if (DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment()) { - ClientCommandRegistrationCallback.EVENT.register(DumpPlayersCommand::register); + if (debugEnabled()) { + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug") + .then(dumpPlayersCommand()) + .then(ItemUtils.dumpHeldItemNbtCommand()) + ))); } } + + private static LiteralArgumentBuilder dumpPlayersCommand() { + return literal("dumpPlayers") + .executes(context -> { + context.getSource().getWorld().getPlayers().forEach(player -> context.getSource().sendFeedback(Text.of("'" + player.getName().getString() + "'"))); + return Command.SINGLE_SUCCESS; + }); + } } diff --git a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java b/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java deleted file mode 100644 index 5f6e0362d0..0000000000 --- a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.hysky.skyblocker.debug; - -import com.mojang.brigadier.Command; -import com.mojang.brigadier.CommandDispatcher; -import de.hysky.skyblocker.SkyblockerMod; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.command.CommandRegistryAccess; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.Text; - -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - -public class DumpPlayersCommand { - - static void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) { - dispatcher.register(literal(SkyblockerMod.NAMESPACE) - .then(literal("debug") - .then(literal("dumpPlayers") - .executes(context -> { - FabricClientCommandSource source = context.getSource(); - - source.getWorld().getEntities().forEach(e -> { - if (e instanceof PlayerEntity player) { - source.sendFeedback(Text.of("'" + player.getName().getString() + "'")); - } - }); - - return Command.SINGLE_SUCCESS; - })))); - } -} diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index ed46677da7..6e80acead1 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -1,7 +1,10 @@ package de.hysky.skyblocker.utils; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; import it.unimi.dsi.fastutil.ints.IntIntPair; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; @@ -18,6 +21,8 @@ import java.util.function.Predicate; import java.util.regex.Pattern; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + public class ItemUtils { public static final String EXTRA_ATTRIBUTES = "ExtraAttributes"; public static final String ID = "id"; @@ -25,6 +30,13 @@ public class ItemUtils { public static final Pattern NOT_DURABILITY = Pattern.compile("[^0-9 /]"); public static final Predicate FUEL_PREDICATE = line -> line.contains("Fuel: "); + public static LiteralArgumentBuilder dumpHeldItemNbtCommand() { + return literal("dumpHeldItemNbt").executes(context -> { + context.getSource().sendFeedback(Text.literal("[Skyblocker Debug] Held Item Nbt: " + context.getSource().getPlayer().getMainHandStack().writeNbt(new NbtCompound()))); + return Command.SINGLE_SUCCESS; + }); + } + public static List getTooltips(ItemStack item) { MinecraftClient client = MinecraftClient.getInstance(); return client.player == null || item == null ? Collections.emptyList() : item.getTooltip(client.player, TooltipContext.Default.BASIC); From ff69b0ee8526a4281efda6e85f1404592de05907 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:01:51 -0500 Subject: [PATCH 2/2] Show armor stands in debug mode --- .../mixin/EntityRenderDispatcherMixin.java | 18 ++++++++++++++++++ .../mixin/LivingEntityRendererMixin.java | 18 ++++++++++++++++++ src/main/resources/skyblocker.mixins.json | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java create mode 100644 src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java diff --git a/src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java b/src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java new file mode 100644 index 0000000000..5cf88588ee --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java @@ -0,0 +1,18 @@ +package de.hysky.skyblocker.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import de.hysky.skyblocker.debug.Debug; +import de.hysky.skyblocker.utils.Utils; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.Entity; +import net.minecraft.entity.decoration.ArmorStandEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(EntityRenderDispatcher.class) +public class EntityRenderDispatcherMixin { + @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isInvisible()Z", ordinal = 1)) + private boolean skyblocker$armorStandHitboxVisible(boolean invisible, E entity) { + return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled()) && invisible; + } +} diff --git a/src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java b/src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java new file mode 100644 index 0000000000..cf927f0cec --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java @@ -0,0 +1,18 @@ +package de.hysky.skyblocker.mixin; + +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 boolean skyblocker$armorStandVisible(boolean visible, T entity) { + return entity instanceof ArmorStandEntity && Utils.isOnHypixel() && Debug.debugEnabled() || visible; + } +} diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json index d7ae26e162..ca5390e02e 100644 --- a/src/main/resources/skyblocker.mixins.json +++ b/src/main/resources/skyblocker.mixins.json @@ -12,6 +12,7 @@ "ClientPlayNetworkHandlerMixin", "DrawContextMixin", "DyeableItemMixin", + "EntityRenderDispatcherMixin", "FarmlandBlockMixin", "GenericContainerScreenHandlerMixin", "HandledScreenMixin", @@ -21,6 +22,7 @@ "ItemMixin", "ItemStackMixin", "LeverBlockMixin", + "LivingEntityRendererMixin", "MinecraftClientMixin", "PlayerListHudMixin", "PlayerSkinProviderMixin",