From a0588bc0fce38990f06e66b5be9c89417217408f Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 5 Feb 2024 22:09:46 -0500 Subject: 24w05a/b --- src/main/java/de/hysky/skyblocker/debug/Debug.java | 1 + .../de/hysky/skyblocker/debug/SnapshotDebug.java | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java (limited to 'src/main/java/de/hysky/skyblocker/debug') diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 86adcac6..5a9d221b 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -20,6 +20,7 @@ public class Debug { 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.dumpHeldItemNbtCommand()) diff --git a/src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java b/src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java new file mode 100644 index 00000000..bd4abd2c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java @@ -0,0 +1,32 @@ +package de.hysky.skyblocker.debug; + +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.SharedConstants; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class SnapshotDebug { + private static final float[] RED = { 1.0f, 0.0f, 0.0f }; + private static final float ALPHA = 0.5f; + private static final float LINE_WIDTH = 8f; + + private static boolean isInSnapshot() { + return !SharedConstants.getGameVersion().isStable(); + } + + static void init() { + if (isInSnapshot()) { + WorldRenderEvents.AFTER_TRANSLUCENT.register(SnapshotDebug::renderTest); + } + } + + private static void renderTest(WorldRenderContext wrc) { + RenderHelper.renderFilledWithBeaconBeam(wrc, new BlockPos(175, 63, -14), RED, ALPHA, true); + RenderHelper.renderLinesFromPoints(wrc, new Vec3d[] { new Vec3d(173, 66, -7.5), new Vec3d(178, 66, -7.5) }, RED, ALPHA, LINE_WIDTH, false); + RenderHelper.renderQuad(wrc, new Vec3d[] { new Vec3d(183, 66, -16), new Vec3d(183, 63, -16), new Vec3d(183, 63, -14), new Vec3d(183, 66, -14) }, RED, ALPHA, false); + RenderHelper.renderText(wrc, Text.of("Skyblocker on " + SharedConstants.getGameVersion().getName() + "!"), new Vec3d(175.5, 67.5, -7.5), false); + } +} -- cgit From 4e2924407645b04c30d4a2823a1d9d0983c2c790 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:16:27 -0500 Subject: 24w09a --- src/main/java/de/hysky/skyblocker/debug/Debug.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/de/hysky/skyblocker/debug') diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 5a9d221b..31823ab0 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -23,7 +23,7 @@ public class Debug { SnapshotDebug.init(); ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug") .then(dumpPlayersCommand()) - .then(ItemUtils.dumpHeldItemNbtCommand()) + .then(ItemUtils.dumpHeldItemCommand()) ))); } } -- cgit From 45bcbe967ac58a2dc5ef606381e1653003ac17e3 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sun, 28 Apr 2024 15:06:24 -0400 Subject: Add invisible armour stand toggle and dumping head textures to debug --- src/main/java/de/hysky/skyblocker/debug/Debug.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/main/java/de/hysky/skyblocker/debug') diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 31823ab0..8c883b30 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -3,17 +3,25 @@ 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.Constants; 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.entity.decoration.ArmorStandEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.text.Text; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; +import java.util.List; + public class Debug { private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); + private static boolean showInvisibleArmorStands = false; + public static boolean debugEnabled() { return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment(); } @@ -24,6 +32,8 @@ public class Debug { ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug") .then(dumpPlayersCommand()) .then(ItemUtils.dumpHeldItemCommand()) + .then(toggleShowingInvisibleArmorStands()) + .then(dumpArmorStandHeadTextures()) ))); } } @@ -35,4 +45,36 @@ public class Debug { return Command.SINGLE_SUCCESS; }); } + + private static LiteralArgumentBuilder toggleShowingInvisibleArmorStands() { + return literal("toggleShowingInvisibleArmorStands") + .executes(context -> { + showInvisibleArmorStands = !showInvisibleArmorStands; + context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.debug.toggledShowingInvisibleArmorStands", showInvisibleArmorStands))); + return Command.SINGLE_SUCCESS; + }); + } + + private static LiteralArgumentBuilder dumpArmorStandHeadTextures() { + return literal("dumpArmorStandHeadTextures") + .executes(context -> { + List armorStands = context.getSource().getWorld().getEntitiesByClass(ArmorStandEntity.class, context.getSource().getPlayer().getBoundingBox().expand(8d), EntityPredicates.NOT_MOUNTED); + + for (ArmorStandEntity armorStand : armorStands) { + Iterable equippedItems = armorStand.getEquippedItems(); + + for (ItemStack stack : equippedItems) { + String texture = ItemUtils.getHeadTexture(stack); + + if (!texture.isEmpty()) context.getSource().sendFeedback(Text.of(texture)); + } + } + + return Command.SINGLE_SUCCESS; + }); + } + + public static boolean shouldShowInvisibleArmorStands() { + return showInvisibleArmorStands; + } } -- cgit