diff options
| author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-28 15:06:24 -0400 |
|---|---|---|
| committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-28 15:06:24 -0400 |
| commit | 45bcbe967ac58a2dc5ef606381e1653003ac17e3 (patch) | |
| tree | 65b14c285a6489acdc070f991b1ca9e798829246 /src/main/java/de/hysky/skyblocker/debug | |
| parent | 75547cb59396252f8e5bde41181b9f27c655ccf2 (diff) | |
| download | Skyblocker-45bcbe967ac58a2dc5ef606381e1653003ac17e3.tar.gz Skyblocker-45bcbe967ac58a2dc5ef606381e1653003ac17e3.tar.bz2 Skyblocker-45bcbe967ac58a2dc5ef606381e1653003ac17e3.zip | |
Add invisible armour stand toggle and dumping head textures to debug
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/debug')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/debug/Debug.java | 42 |
1 files changed, 42 insertions, 0 deletions
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<FabricClientCommandSource> 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<FabricClientCommandSource> dumpArmorStandHeadTextures() { + return literal("dumpArmorStandHeadTextures") + .executes(context -> { + List<ArmorStandEntity> armorStands = context.getSource().getWorld().getEntitiesByClass(ArmorStandEntity.class, context.getSource().getPlayer().getBoundingBox().expand(8d), EntityPredicates.NOT_MOUNTED); + + for (ArmorStandEntity armorStand : armorStands) { + Iterable<ItemStack> 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; + } } |
