diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/model/AbstractModelGui.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/model/AbstractModelGui.java index a0a98159d..831b38789 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/model/AbstractModelGui.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/model/AbstractModelGui.java @@ -10,12 +10,14 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.components.Widget; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.SimpleTexture; import net.minecraft.network.chat.*; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -32,6 +34,8 @@ public abstract class AbstractModelGui guiNumber; private final List> modelPackList; @@ -285,6 +289,10 @@ private void drawTabIcon(PoseStack poseStack, int middleX, int middleY) { CustomModelPack pack = modelPackList.get(guiNumber.tabToPackIndex(index, getPageIndex())); ResourceLocation icon = pack.getIcon(); if (icon != null) { + AbstractTexture iconTexture = Minecraft.getInstance().textureManager.getTexture(icon, EMPTY_ICON_TEXTURE); + if (EMPTY_ICON_TEXTURE.equals(iconTexture)) { + icon = EMPTY_ICON; + } if (pack.getIconAnimation() == CustomModelPack.AnimationState.UNCHECK) { checkIconAnimation(pack, icon); } diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/CustomPackLoader.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/CustomPackLoader.java index 898eb9177..34a920aef 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/CustomPackLoader.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/CustomPackLoader.java @@ -242,7 +242,7 @@ private static void loadGeckoMaidModelElement(Path rootPath, MaidModelInfo maidM registerFilePackTexture(rootPath, maidModelItem.getTexture()); // 加载动画 List animation = maidModelItem.getAnimation(); - if (animation == null || animation.size() == 0) { + if (animation == null || animation.isEmpty()) { return; } AnimationFile animationData = new AnimationFile(); @@ -283,7 +283,7 @@ private static void loadGeckoChairModelElement(Path rootPath, ChairModelInfo cha registerFilePackTexture(rootPath, chairModelItem.getTexture()); // 加载动画 List animation = chairModelItem.getAnimation(); - if (animation == null || animation.size() == 0) { + if (animation == null || animation.isEmpty()) { return; } AnimationFile animationData = new AnimationFile(); @@ -388,7 +388,7 @@ private static void loadGeckoMaidModelElement(ZipFile zipFile, MaidModelInfo mai registerZipPackTexture(zipFile.getName(), maidModelItem.getTexture()); // 加载动画 List animation = maidModelItem.getAnimation(); - if (animation == null || animation.size() == 0) { + if (animation == null || animation.isEmpty()) { return; } AnimationFile animationData = new AnimationFile(); @@ -430,7 +430,7 @@ private static void loadGeckoChairModelElement(ZipFile zipFile, ChairModelInfo c registerZipPackTexture(zipFile.getName(), chairModelItem.getTexture()); // 加载动画 List animation = chairModelItem.getAnimation(); - if (animation == null || animation.size() == 0) { + if (animation == null || animation.isEmpty()) { return; } AnimationFile animationData = new AnimationFile(); @@ -468,7 +468,7 @@ private static void putMaidModelData(MaidModelInfo maidModelItem, BedrockModel 0) { + if (animations != null && !animations.isEmpty()) { MAID_MODELS.putAnimation(id, animations); } } @@ -519,7 +519,7 @@ private static void loadChairModelElement(Path rootPath, ChairModelInfo chairMod // 如果加载的模型不为空 CHAIR_MODELS.putModel(id, modelJson); CHAIR_MODELS.putInfo(id, chairModelItem); - if (animations != null && animations.size() > 0) { + if (animations != null && !animations.isEmpty()) { CHAIR_MODELS.putAnimation(id, animations); } // 打印日志 @@ -573,7 +573,7 @@ private static void loadChairModelElement(ZipFile zipFile, ChairModelInfo chairM // 如果加载的模型不为空 CHAIR_MODELS.putModel(id, modelJson); CHAIR_MODELS.putInfo(id, chairModelItem); - if (animations != null && animations.size() > 0) { + if (animations != null && !animations.isEmpty()) { CHAIR_MODELS.putAnimation(id, animations); } // 打印日志 diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/pojo/CustomModelPack.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/pojo/CustomModelPack.java index 53f32f6ae..20d143dc1 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/pojo/CustomModelPack.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/resource/pojo/CustomModelPack.java @@ -1,5 +1,6 @@ package com.github.tartaricacid.touhoulittlemaid.client.resource.pojo; +import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; import com.google.gson.JsonSyntaxException; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -103,6 +104,9 @@ public CustomModelPack decorate() { if (author == null) { author = Collections.EMPTY_LIST; } + if (icon == null) { + icon = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/gui/empty_model_pack_icon.png"); + } if (iconDelay <= 0) { iconDelay = 1; } diff --git a/src/main/resources/assets/touhou_little_maid/textures/gui/empty_model_pack_icon.png b/src/main/resources/assets/touhou_little_maid/textures/gui/empty_model_pack_icon.png new file mode 100644 index 000000000..9919cb841 Binary files /dev/null and b/src/main/resources/assets/touhou_little_maid/textures/gui/empty_model_pack_icon.png differ diff --git a/src/main/resources/assets/touhou_little_maid/tlm_custom_pack/touhou_little_maid-1.0.0.zip b/src/main/resources/assets/touhou_little_maid/tlm_custom_pack/touhou_little_maid-1.0.0.zip index acb655a44..a70c22d25 100644 Binary files a/src/main/resources/assets/touhou_little_maid/tlm_custom_pack/touhou_little_maid-1.0.0.zip and b/src/main/resources/assets/touhou_little_maid/tlm_custom_pack/touhou_little_maid-1.0.0.zip differ