diff options
Diffstat (limited to 'src/main/java')
6 files changed, 66 insertions, 23 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; + } } diff --git a/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java b/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java index 05fe9148..79d13068 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java @@ -13,6 +13,6 @@ import org.spongepowered.asm.mixin.injection.At; 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()) && invisible; + return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled() || !Debug.shouldShowInvisibleArmorStands()) && invisible; } } diff --git a/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java b/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java index ba3e5067..60fa7dec 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java @@ -13,6 +13,6 @@ import org.spongepowered.asm.mixin.injection.At; 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() || visible; + return entity instanceof ArmorStandEntity && Utils.isOnHypixel() && Debug.debugEnabled() && Debug.shouldShowInvisibleArmorStands() || visible; } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java index 8343c6a5..75ba700e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -4,6 +4,7 @@ import com.mojang.authlib.properties.Property; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dungeon.LividColor; import de.hysky.skyblocker.skyblock.end.TheEnd; +import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.SlayerUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; @@ -104,23 +105,12 @@ public class MobGlow { private static boolean isNukekubiHead(ArmorStandEntity entity) { for (ItemStack armorItem : entity.getArmorItems()) { - // hacky way to check if an item is a player head w/o - // some shenanigans - if (!armorItem.isOf(Items.PLAYER_HEAD)) - continue; - // eb07594e2df273921a77c101d0bfdfa1115abed5b9b2029eb496ceba9bdbb4b3 is texture id for the nukekubi head, // compare against it to exclusively find armorstands that are nukekubi heads - ProfileComponent profile = armorItem.get(DataComponentTypes.PROFILE); - if (profile != null) { - // get the texture of the nukekubi head item itself and compare it - String texture = profile.properties().get("textures").stream() - .map(Property::value) - .findFirst() - .orElse("None"); - - return texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="); - } + // get the texture of the nukekubi head item itself and compare it + String texture = ItemUtils.getHeadTexture(armorItem); + + return texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="); } return false; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/VisitorHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/VisitorHelper.java index ff6086d3..d6015748 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/VisitorHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/VisitorHelper.java @@ -96,11 +96,9 @@ public class VisitorHelper { } private static @Nullable String getTextureOrNull(ItemStack stack) { - if (!stack.isOf(Items.PLAYER_HEAD) || stack.get(DataComponentTypes.PROFILE) == null) return null; - return stack.get(DataComponentTypes.PROFILE).properties().get("textures").stream() - .map(Property::value) - .findFirst() - .orElse(null); + String texture = ItemUtils.getHeadTexture(stack); + + return texture.isEmpty() ? null : texture; } private static void processLore(String visitorName, @Nullable String visitorTexture, List<Text> loreList) { diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index 32ca36ca..086686a7 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.utils; import com.google.gson.Gson; import com.google.gson.JsonParser; +import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -199,7 +200,19 @@ public class ItemUtils { } public static PropertyMap propertyMapWithTexture(String textureValue) { - return Codecs.GAME_PROFILE_PROPERTY_MAP.parse(JsonOps.INSTANCE, JsonParser.parseString("[{\"name\":\"textures\",\"value\":\"" + textureValue + "\"}]")).getOrThrow(); + return Codecs.GAME_PROFILE_PROPERTY_MAP.parse(JsonOps.INSTANCE, JsonParser.parseString("[{\"name\":\"textures\",\"value\":\"" + textureValue + "\"}]")).getOrThrow(); + } + + public static String getHeadTexture(ItemStack stack) { + if (!stack.isOf(Items.PLAYER_HEAD) || !stack.contains(DataComponentTypes.PROFILE)) return ""; + + ProfileComponent profile = stack.get(DataComponentTypes.PROFILE); + String texture = profile.properties().get("textures").stream() + .map(Property::value) + .findFirst() + .orElse(""); + + return texture; } public static ItemStack getSkyblockerStack() { |