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 c15dfe6bc..2806d17d2 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 @@ -9,6 +9,7 @@ import com.google.common.collect.Lists; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.button.Button; @@ -30,6 +31,7 @@ public abstract class AbstractModelGui guiNumber; private final List> modelPackList; @@ -282,6 +284,10 @@ private void drawTabIcon(MatrixStack matrixStack, int middleX, int middleY) { CustomModelPack pack = modelPackList.get(guiNumber.tabToPackIndex(index, getPageIndex())); ResourceLocation icon = pack.getIcon(); if (icon != null) { + Texture iconTexture = Minecraft.getInstance().textureManager.getTexture(icon); + if (iconTexture == null) { + 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 1647bbe24..c2ccf70f8 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 deb36e969..1c70f04fc 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