diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/ClientModelManager.java b/src/main/java/com/elfmcys/yesstevemodel/client/ClientModelManager.java index 54fd92aa..a05b27df 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/ClientModelManager.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/ClientModelManager.java @@ -51,10 +51,9 @@ public class ClientModelManager { public static Map> MODELS = Maps.newHashMap(); public static Map> SCALE_INFO = Maps.newHashMap(); - public static Map> EXTRA_INFO = Maps.newHashMap(); - public static Map EXTRA_ANIMATION_NAME = Maps.newHashMap(); + public static Map> META_DATA = Maps.newHashMap(); + public static Map EXTRA_INFO = Maps.newHashMap(); public static AnimationFile DEFAULT_ANIMATION_FILE = new AnimationFile(); - public static AnimationFile DEFAULT_ARROW_ANIMATION_FILE = new AnimationFile(); public static List CACHE_MD5 = Lists.newArrayList(); public static List AUTH_MODELS = Lists.newArrayList(); public static byte[] PASSWORD; @@ -105,7 +104,7 @@ private static void registerGeo(ResourceLocation modelId, String partName, byte[ public static void registerTexture(ResourceLocation modelId, Map mapData) { List textures = Lists.newArrayList(); for (String name : mapData.keySet()) { - if (!name.equals(IArrowExtraInfo.TEXTURE_NAME)) { + if (isModelTexture(ModelIdUtil.getInfoId(modelId), name)) { ResourceLocation textureId = ModelIdUtil.getSubModelId(modelId, name); textures.add(textureId); } @@ -117,6 +116,12 @@ public static void registerTexture(ResourceLocation modelId, Map } } + private static boolean isModelTexture(ResourceLocation infoId, String name) { + if (name.equals(IArrowExtraInfo.TEXTURE_NAME)) return false; + final ExtraInfo extraInfo = EXTRA_INFO.get(infoId); + return !name.equals(extraInfo.getGuiBackground()) && !name.equals(extraInfo.getGuiForeground()); + } + private static void registerTexture(ResourceLocation textureId, byte[] data) { // 确保主线程上传 final Minecraft mc = Minecraft.getMinecraft(); @@ -140,6 +145,7 @@ private static void registerAnimations(ResourceLocation mainId, Map { if (!main.animations().containsKey(name)) { main.putAnimation(name, action); @@ -168,6 +174,9 @@ private static AnimationFile getAnimationFile(String file) { return animationFile; } + /** + * @return main animation + */ private static AnimationFile mergeAnimationFile(AnimationFile main, AnimationFile other) { other.animations().forEach(main::putAnimation); return main; @@ -178,11 +187,7 @@ public static void loadDefaultModel() { ModelData data = FolderFormat.getModelData(ServerModelManager.BUILTIN, "default", false); data.getAnimation().forEach((name, bytes) -> { AnimationFile animationFile = getAnimationFile(new String(bytes, StandardCharsets.UTF_8)); - if ("arrow".equals(name)) { - mergeAnimationFile(DEFAULT_ARROW_ANIMATION_FILE, animationFile); - } else { - mergeAnimationFile(DEFAULT_ANIMATION_FILE, animationFile); - } + if (!"arrow".equals(name)) mergeAnimationFile(DEFAULT_ANIMATION_FILE, animationFile); }); ClientModelManager.registerAll(data); } catch (IOException e) { @@ -195,8 +200,8 @@ public static void sendSyncModelMessage() { CACHE_MD5.clear(); AUTH_MODELS.clear(); SCALE_INFO.clear(); + META_DATA.clear(); EXTRA_INFO.clear(); - EXTRA_ANIMATION_NAME.clear(); ConditionManager.clear(); String[] md5Info = getMd5Info(); SyncModelFiles syncModelFiles = new SyncModelFiles(md5Info); @@ -230,23 +235,24 @@ private static byte[] getBytes(Path root, String fileName) throws IOException { private static void addExtraInfo(ResourceLocation modelId, @Nullable ExtraInfo extraInfo) { if (extraInfo == null) return; ResourceLocation infoId = ModelIdUtil.getInfoId(modelId); - EXTRA_INFO.put(infoId, handleExtraInfo(extraInfo)); + EXTRA_INFO.put(infoId, extraInfo); + META_DATA.put(infoId, readMetaData(extraInfo)); if (extraInfo.getFree()) { AUTH_MODELS.remove(modelId.getPath()); } - if (extraInfo.getExtraAnimationNames() != null && extraInfo.getExtraAnimationNames().length > 0) { - EXTRA_ANIMATION_NAME.put(infoId, extraInfo.getExtraAnimationNames()); + if (modelId.getPath().equals("default") && extraInfo.getPreviewAnimation() != null) { + DEFAULT_ANIMATION_FILE.animations().remove(extraInfo.getPreviewAnimation()); } } @Nullable - private static List handleExtraInfo(@Nullable ExtraInfo extraInfo) { + private static List readMetaData(@Nullable ExtraInfo extraInfo) { if (extraInfo == null || StringUtils.isBlank(extraInfo.getName())) { return null; } List component = Lists.newArrayList(); component.add(TextFormatting.GOLD + extraInfo.getName()); - if (StringUtils.isNoneBlank(extraInfo.getTips())) { + if (extraInfo.getTips() != null && StringUtils.isNoneBlank(extraInfo.getTips())) { String[] split = extraInfo.getTips().split("\n"); Arrays.stream(split).forEach(s -> component.add(TextFormatting.GRAY + I18n.format(s))); } diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/AnimationRouletteScreen.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/AnimationRouletteScreen.java index 370e6db1..e912c052 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/AnimationRouletteScreen.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/AnimationRouletteScreen.java @@ -24,13 +24,14 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; +import javax.annotation.Nullable; import java.io.IOException; public class AnimationRouletteScreen extends Screen { private int x; private int y; private int selectId = -1; - private String[] names; + private @Nullable String[] names; public AnimationRouletteScreen() { } @@ -43,9 +44,7 @@ public void initGui() { if (this.mc != null && this.mc.player != null) { CapabilityEvent.getModelInfoCap(this.mc.player).ifPresent(cap -> { ResourceLocation modelId = cap.getModelId(); - if (ClientModelManager.EXTRA_ANIMATION_NAME.containsKey(ModelIdUtil.getInfoId(modelId))) { - this.names = ClientModelManager.EXTRA_ANIMATION_NAME.get(ModelIdUtil.getInfoId(modelId)); - } + this.names = ClientModelManager.EXTRA_INFO.get(ModelIdUtil.getInfoId(modelId)).getExtraAnimationNames(); }); } } diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/ConfigScreen.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/ConfigScreen.java index fc01de74..23dce257 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/ConfigScreen.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/ConfigScreen.java @@ -24,17 +24,17 @@ public void initGui() { this.addButton(new FlatColorButton(x + 5, y, 80, 18, I18n.format("gui.yes_steve_model.model.return"), (b) -> this.mc.displayGuiScreen(this.parent))); - this.addButton(new ConfigCheckBox(x + 5, y + 25, "disable_self_model", this.fontRenderer, + this.addButton(new ConfigCheckBox(x + 5, y + 25, "config.disable_self_model", this.fontRenderer, GeneralConfig.DISABLE_SELF_MODEL, (value) -> GeneralConfig.DISABLE_SELF_MODEL = value)); - this.addButton(new ConfigCheckBox(x + 5, y + 47, "disable_other_model", this.fontRenderer, + this.addButton(new ConfigCheckBox(x + 5, y + 47, "config.disable_other_model", this.fontRenderer, GeneralConfig.DISABLE_OTHER_MODEL, (value) -> GeneralConfig.DISABLE_OTHER_MODEL = value)); - this.addButton(new ConfigCheckBox(x + 5, y + 69, "print_animation_roulette_msg", this.fontRenderer, + this.addButton(new ConfigCheckBox(x + 5, y + 69, "config.print_animation_roulette_msg", this.fontRenderer, GeneralConfig.PRINT_ANIMATION_ROULETTE_MSG, (value) -> GeneralConfig.PRINT_ANIMATION_ROULETTE_MSG = value)); - this.addButton(new ConfigCheckBox(x + 5, y + 91, "disable_self_hands", this.fontRenderer, + this.addButton(new ConfigCheckBox(x + 5, y + 91, "config.disable_self_hands", this.fontRenderer, GeneralConfig.DISABLE_SELF_HANDS, (value) -> GeneralConfig.DISABLE_SELF_HANDS = value)); - this.addButton(new ConfigCheckBox(x + 5, y + 112, "disable_player_render", this.fontRenderer, + this.addButton(new ConfigCheckBox(x + 5, y + 112, "config.disable_player_render", this.fontRenderer, ExtraPlayerScreenConfig.DISABLE_PLAYER_RENDER, (value) -> ExtraPlayerScreenConfig.DISABLE_PLAYER_RENDER = value)); - this.addButton(new ConfigCheckBox(x + 5, y + 134, "disable_arrows_model", this.fontRenderer, + this.addButton(new ConfigCheckBox(x + 5, y + 134, "config.disable_arrows_model", this.fontRenderer, GeneralConfig.DISABLE_ARROWS_MODEL, (value) -> GeneralConfig.DISABLE_ARROWS_MODEL = value)); } diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerModelScreen.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerModelScreen.java index a04887ba..956045c7 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerModelScreen.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerModelScreen.java @@ -4,7 +4,10 @@ import com.elfmcys.yesstevemodel.client.ClientModelManager; import com.elfmcys.yesstevemodel.client.gui.button.*; import com.elfmcys.yesstevemodel.client.input.PlayerModelScreenKey; +import com.elfmcys.yesstevemodel.config.Config; +import com.elfmcys.yesstevemodel.config.GeneralConfig; import com.elfmcys.yesstevemodel.event.CapabilityEvent; +import com.elfmcys.yesstevemodel.geckolib3.geo.raw.pojo.ExtraInfo; import com.elfmcys.yesstevemodel.util.ModelIdUtil; import com.elfmcys.yesstevemodel.util.RenderUtil; import com.google.common.collect.Lists; @@ -115,6 +118,15 @@ public void initGui() { }).setTooltips("gui.yes_steve_model.model.texture")); this.addButton(new StarButton(this.x + 110, this.y + 5)); + this.addButton(new ConfigCheckBox(this.x + 5, this.y - 22, "show_model_id_first", this.fontRenderer, + GeneralConfig.SHOW_MODEL_ID_FIRST, value -> GeneralConfig.SHOW_MODEL_ID_FIRST = value) { + @Override + public void onPress() { + super.onPress(); + Config.save(); + } + }); + this.addButton(new FlatIconButton(this.x + 328, this.y + 5, 18, 18, 32, 0, (b) -> { if (this.category != Category.ALL) { this.category = Category.ALL; @@ -173,9 +185,9 @@ public void initGui() { int yStart = this.y + 28 + 93 * (i / 5); CapabilityEvent.getAuthModelsCap(this.player).ifPresent(cap -> { if (ClientModelManager.AUTH_MODELS.contains(id.getPath()) && !cap.containModel(id)) { - this.addButton(new ModelButton(xStart, yStart, true, Pair.of(id, this.models.get(id)), ClientModelManager.EXTRA_INFO.get(ModelIdUtil.getInfoId(id)), this.player)); + this.addButton(new ModelButton(xStart, yStart, true, Pair.of(id, this.models.get(id)), ClientModelManager.META_DATA.get(ModelIdUtil.getInfoId(id)), this.player)); } else { - this.addButton(new ModelButton(xStart, yStart, false, Pair.of(id, this.models.get(id)), ClientModelManager.EXTRA_INFO.get(ModelIdUtil.getInfoId(id)), this.player)); + this.addButton(new ModelButton(xStart, yStart, false, Pair.of(id, this.models.get(id)), ClientModelManager.META_DATA.get(ModelIdUtil.getInfoId(id)), this.player)); } }); } @@ -197,6 +209,10 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { CapabilityEvent.getModelInfoCap(this.player).ifPresent(cap -> { String modelName = cap.getModelId().getPath(); + final ExtraInfo extraInfo = ClientModelManager.EXTRA_INFO.get(ModelIdUtil.getInfoId(cap.getModelId())); + if (extraInfo.getName() != null && !extraInfo.getName().isEmpty()) { + modelName = extraInfo.getName(); + } List modelNameSplit = this.fontRenderer.listFormattedStringToWidth(modelName, 125); int lineY = this.y + 205; for (String line : modelNameSplit) { diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerTextureScreen.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerTextureScreen.java index 01c29e53..c09aadce 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerTextureScreen.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/PlayerTextureScreen.java @@ -45,7 +45,6 @@ public class PlayerTextureScreen extends Screen { private float pitch = -5; private boolean showGround = true; - public PlayerTextureScreen(PlayerModelScreen parent, ResourceLocation modelId, List textures) { this.parent = parent; this.modelId = modelId; @@ -141,12 +140,13 @@ public void initGui() { @Override public void drawScreen(int mouseX, int mouseY, float partialTick) { - //GlStateManager.translate(0, 0, -1000); + final float zLevel = this.zLevel; + this.zLevel -= 1000; this.drawDefaultBackground(); this.drawGradientRect(this.x, this.y + 22, this.x + 90, this.y + 235, 0xff_222222, 0xff_222222); this.drawGradientRect(this.x + 93, this.y, this.x + 299, this.y + 235, 0xff_222222, 0xff_222222); this.drawGradientRect(this.x + 302, this.y, this.x + 420, this.y + 235, 0xff_222222, 0xff_222222); - //GlStateManager.translate(0, 0, 1000); + this.zLevel = zLevel; CapabilityEvent.getModelInfoCap(this.player).ifPresent(cap -> { RenderUtil.scissor(this.x + 93, this.y, 206, 235); diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ConfigCheckBox.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ConfigCheckBox.java index b22034a8..dd6fcd24 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ConfigCheckBox.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ConfigCheckBox.java @@ -11,7 +11,7 @@ public class ConfigCheckBox extends Checkbox { * @param font 计算宽度用,文本较长时按钮宽度(点击区域)也会跟着变长。 */ public ConfigCheckBox(int pX, int pY, String key, @Nonnull FontRenderer font, boolean current, Consumer setter) { - super(pX, pY, I18n.format("gui.yes_steve_model.config." + key), font, current, (button -> { + super(pX, pY, I18n.format("gui.yes_steve_model." + key), font, current, (button -> { setter.accept(((Checkbox) button).selected()); })); } diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatColorButton.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatColorButton.java index 9cc97f38..bb65ee68 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatColorButton.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatColorButton.java @@ -36,7 +36,7 @@ public void renderToolTip(GuiScreen screen, int pMouseX, int pMouseY) { } @Override - public void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { + protected void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { FontRenderer font = mc.fontRenderer; if (this.isSelect) { this.drawGradientRect(this.x, this.y, this.x + this.width, this.y + this.height, 0xff_1E90FF, 0xff_1E90FF); diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatIconButton.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatIconButton.java index 3060d2df..6aa02b92 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatIconButton.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/FlatIconButton.java @@ -20,7 +20,7 @@ public FlatIconButton(int x, int y, int width, int height, int textureX, int tex } @Override - public void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { + protected void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { super.renderWidget(mc, mouseX, mouseY, pPartialTick); mc.getTextureManager().bindTexture(ICON); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelButton.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelButton.java index 201e267c..9da6648d 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelButton.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelButton.java @@ -3,9 +3,13 @@ import com.elfmcys.yesstevemodel.YesSteveModel; import com.elfmcys.yesstevemodel.bukkit.message.OpenModelGuiMessage; import com.elfmcys.yesstevemodel.bukkit.message.SetNpcModelAndTexture; +import com.elfmcys.yesstevemodel.client.ClientModelManager; +import com.elfmcys.yesstevemodel.config.GeneralConfig; import com.elfmcys.yesstevemodel.event.CapabilityEvent; +import com.elfmcys.yesstevemodel.geckolib3.geo.raw.pojo.ExtraInfo; import com.elfmcys.yesstevemodel.network.NetworkHandler; import com.elfmcys.yesstevemodel.network.message.SetModelAndTexture; +import com.elfmcys.yesstevemodel.util.ModelIdUtil; import com.elfmcys.yesstevemodel.util.RenderUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; @@ -28,7 +32,15 @@ public class ModelButton extends Button { private final int color; private final @Nullable List tooltips; private final EntityPlayer player; + private final String modelName; + private final String previewAnimation; + private final boolean disablePreviewRotation; + private final @Nullable ResourceLocation backgroundTexture; + private final @Nullable ResourceLocation foregroundTexture; + /** + * @param modelInfo Model Id, Textures + */ public ModelButton(int pX, int pY, boolean needAuth, Pair> modelInfo, @Nullable List tooltips, EntityPlayer player) { super(pX, pY, 52, 90, modelInfo.getLeft().getPath(), (b) -> { }); @@ -37,6 +49,17 @@ public ModelButton(int pX, int pY, boolean needAuth, Pair { + if (!this.previewAnimation.isEmpty() && !custom.hasPreviewAnimation(this.previewAnimation)) { + custom.setPreviewAnimation(this.previewAnimation); + } + }, this.disablePreviewRotation); GL11.glDisable(GL11.GL_SCISSOR_TEST); - - List split = font.listFormattedStringToWidth(this.displayString, 45); + GlStateManager.disableDepth(); + // 前景图 + if (this.foregroundTexture != null) { + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + mc.getTextureManager().bindTexture(this.foregroundTexture); + drawModalRectWithCustomSizedTexture(this.x, this.y, 0.0F, 0.0F, this.width, this.height, 52, 90); + GlStateManager.disableBlend(); + } + // 文字 + final String modelName = GeneralConfig.SHOW_MODEL_ID_FIRST || this.modelName.isEmpty() ? this.displayString : this.modelName; + List split = font.listFormattedStringToWidth(modelName, 45); if (split.size() > 1) { this.drawCenteredString(font, split.get(0), this.x + this.width / 2, this.y + this.height - 19, 0xF3EFE0); this.drawCenteredString(font, split.get(1), this.x + this.width / 2, this.y + this.height - 10, 0xF3EFE0); } else { - this.drawCenteredString(font, this.displayString, this.x + this.width / 2, this.y + this.height - 15, 0xF3EFE0); + this.drawCenteredString(font, modelName, this.x + this.width / 2, this.y + this.height - 15, 0xF3EFE0); } + // 悬停边框 if (!this.needAuth && this.isMouseOver()) { this.drawGradientRect(this.x, this.y + 1, this.x + 1, this.y + this.height - 1, 0xff_F3EFE0, 0xff_F3EFE0); this.drawGradientRect(this.x, this.y, this.x + this.width, this.y + 1, 0xff_F3EFE0, 0xff_F3EFE0); this.drawGradientRect(this.x + this.width - 1, this.y + 1, this.x + this.width, this.y + this.height - 1, 0xff_F3EFE0, 0xff_F3EFE0); this.drawGradientRect(this.x, this.y + this.height - 1, this.x + this.width, this.y + this.height, 0xff_F3EFE0, 0xff_F3EFE0); } - + // 锁定遮罩 + if (this.needAuth) { + this.drawGradientRect(this.x, this.y, this.x + this.width, this.y + this.height, 0x9f_222222, 0x9f_222222); + } + // 收藏图标 CapabilityEvent.getStarModelsCap(mc.player).ifPresent(cap -> { if (cap.containModel(this.modelInfo.getLeft())) { mc.getTextureManager().bindTexture(ICON); @@ -87,10 +140,7 @@ public void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pa this.drawTexturedModalRect(this.x + this.width - 14, this.y, 16, 0, 16, 16); } }); - - if (this.needAuth) { - this.drawGradientRect(this.x, this.y, this.x + this.width, this.y + this.height, 0x9f_222222, 0x9f_222222); - } + GlStateManager.enableDepth(); } public void renderComponentTooltip(GuiScreen screen, int pMouseX, int pMouseY) { diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelInfoButton.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelInfoButton.java index c263a548..036b63dd 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelInfoButton.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/ModelInfoButton.java @@ -20,7 +20,7 @@ public ModelInfoButton(int pX, int pY, int pHeight, RequestServerModelInfo.Info } @Override - public void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { + protected void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { FontRenderer font = mc.fontRenderer; int color = this.isSelect ? 0xff_1E90FF : 0xff_434242; this.drawGradientRect(this.x, this.y, this.x + this.width, this.y + this.height, color, color); diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/StarButton.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/StarButton.java index f7b8c626..6673285d 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/StarButton.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/StarButton.java @@ -20,7 +20,7 @@ public StarButton(int x, int y) { } @Override - public void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { + protected void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float pPartialTick) { super.renderWidget(mc, mouseX, mouseY, pPartialTick); mc.getTextureManager().bindTexture(ICON); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/TextureButton.java b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/TextureButton.java index 2b90fefd..0da55ef9 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/TextureButton.java +++ b/src/main/java/com/elfmcys/yesstevemodel/client/gui/button/TextureButton.java @@ -45,12 +45,12 @@ public void onPress() { } @Override - public void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTick) { + protected void renderWidget(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTick) { FontRenderer font = mc.fontRenderer; this.drawGradientRect(this.x, this.y, this.x + this.width, this.y + this.height, 0xFF_434242, 0xFF_434242); RenderUtil.scissor(this.x, this.y, this.width, this.height - 20); - RenderUtil.renderEntityInInventory(this.x + this.width / 2, this.y + this.height / 2 + 24, 35, mc.player, this.modelId, this.textureId); + RenderUtil.renderTextureButtonEntity(this.x + this.width / 2, this.y + this.height / 2 + 24, 35, mc.player, this.modelId, this.textureId); GL11.glDisable(GL11.GL_SCISSOR_TEST); List split = font.listFormattedStringToWidth(this.name, 50); diff --git a/src/main/java/com/elfmcys/yesstevemodel/config/GeneralConfig.java b/src/main/java/com/elfmcys/yesstevemodel/config/GeneralConfig.java index 3979ccb1..605a9dd5 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/config/GeneralConfig.java +++ b/src/main/java/com/elfmcys/yesstevemodel/config/GeneralConfig.java @@ -11,6 +11,7 @@ public class GeneralConfig { public static boolean DISABLE_OTHER_MODEL = false; public static boolean DISABLE_SELF_HANDS = false; public static boolean DISABLE_ARROWS_MODEL = false; + public static boolean SHOW_MODEL_ID_FIRST = false; public static String DEFAULT_MODEL_ID = "default"; public static String DEFAULT_MODEL_TEXTURE = "default.png"; @@ -53,6 +54,12 @@ static void build(@Nonnull ConfigBuilder builder) { "Prevents rendering of arrows model" ); + SHOW_MODEL_ID_FIRST = builder.get( + "ShowModelIdFirst", + SHOW_MODEL_ID_FIRST, + "Whether to display model ID first in the model selection screen, instead of the model name filled in by the model author." + ); + DEFAULT_MODEL_ID = builder.get( "DefaultModelId", DEFAULT_MODEL_ID, diff --git a/src/main/java/com/elfmcys/yesstevemodel/geckolib3/geo/raw/pojo/ExtraInfo.java b/src/main/java/com/elfmcys/yesstevemodel/geckolib3/geo/raw/pojo/ExtraInfo.java index ffe4a685..9e16ccbe 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/geckolib3/geo/raw/pojo/ExtraInfo.java +++ b/src/main/java/com/elfmcys/yesstevemodel/geckolib3/geo/raw/pojo/ExtraInfo.java @@ -3,8 +3,10 @@ import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; +import javax.annotation.Nullable; import java.io.Serializable; +@SuppressWarnings("unused") public class ExtraInfo implements Serializable { @SerializedName("name") private String name; @@ -18,7 +20,16 @@ public class ExtraInfo implements Serializable { private String license = "All Rights Reserved"; @SerializedName("free") private boolean free = false; + @SerializedName("preview_animation") + private String previewAnimation = "idle"; + @SerializedName("disable_preview_rotation") + private boolean disablePreviewRotation = false; + @SerializedName("gui_foreground") + private String guiForeground = StringUtils.EMPTY; + @SerializedName("gui_background") + private String guiBackground = StringUtils.EMPTY; + @Nullable public String getName() { return this.name; } @@ -27,6 +38,7 @@ public void setName(String name) { this.name = name; } + @Nullable public String getTips() { return this.tips; } @@ -35,6 +47,7 @@ public void setTips(String tips) { this.tips = tips; } + @Nullable public String[] getExtraAnimationNames() { return this.extraAnimationNames; } @@ -43,6 +56,7 @@ public void setExtraAnimationNames(String[] extraAnimationNames) { this.extraAnimationNames = extraAnimationNames; } + @Nullable public String[] getAuthors() { return this.authors; } @@ -51,6 +65,7 @@ public void setAuthors(String[] authors) { this.authors = authors; } + @Nullable public String getLicense() { return this.license; } @@ -66,4 +81,39 @@ public boolean getFree() { public void setFree(boolean free) { this.free = free; } + + @Nullable + public String getPreviewAnimation() { + return this.previewAnimation; + } + + public void setPreviewAnimation(String previewAnimation) { + this.previewAnimation = previewAnimation; + } + + public boolean getDisablePreviewRotation() { + return this.disablePreviewRotation; + } + + public void setDisablePreviewRotation(boolean disablePreviewRotation) { + this.disablePreviewRotation = disablePreviewRotation; + } + + @Nullable + public String getGuiForeground() { + return this.guiForeground; + } + + public void setGuiForeground(String guiForeground) { + this.guiForeground = guiForeground; + } + + @Nullable + public String getGuiBackground() { + return this.guiBackground; + } + + public void setGuiBackground(String guiBackground) { + this.guiBackground = guiBackground; + } } diff --git a/src/main/java/com/elfmcys/yesstevemodel/util/RenderUtil.java b/src/main/java/com/elfmcys/yesstevemodel/util/RenderUtil.java index 1e55881f..6c58d013 100644 --- a/src/main/java/com/elfmcys/yesstevemodel/util/RenderUtil.java +++ b/src/main/java/com/elfmcys/yesstevemodel/util/RenderUtil.java @@ -17,6 +17,7 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityBoat; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityPig; @@ -82,6 +83,12 @@ public static void renderTextureScreenEntity(float pPosX, float pPosY, float pSc player.rotationPitch = 0; player.rotationYawHead = player.rotationYaw; player.prevRotationYawHead = player.rotationYaw; + if (player.getRidingEntity() instanceof EntityLivingBase vehicle) { + float vehicleYRot = vehicle.rotationYaw; + GlStateManager.rotate(vehicleYRot + yaw, 0, 1, 0); + player.rotationYawHead = vehicleYRot; + player.prevRotationYawHead = vehicleYRot; + } boolean sleeping = player.sleeping; BlockPos bedLocation = player.bedLocation; float renderOffsetX = player.renderOffsetX; @@ -243,7 +250,7 @@ private static void renderExtraEntity(float yaw, EntityPlayer player, RenderMana OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F); } - public static void renderEntityInInventory(int pPosX, int pPosY, int pScale, EntityPlayer player, ResourceLocation modelId, ResourceLocation textureId, Consumer consumer) { + public static void renderEntityInInventory(int pPosX, int pPosY, int pScale, EntityPlayer player, ResourceLocation modelId, ResourceLocation textureId, Consumer consumer, boolean disableRot) { if (player == null) { return; } @@ -252,25 +259,30 @@ public static void renderEntityInInventory(int pPosX, int pPosY, int pScale, Ent IAnimatable animatable = AnimatableCacheUtil.ANIMATABLE_CACHE.get(modelId, CustomPlayerEntity::new); if (animatable instanceof CustomPlayerEntity entity) { consumer.accept(entity); - renderModel(pPosX, pPosY, (float) pScale, player, modelId, textureId, renderer, entity); + renderModel(pPosX, pPosY, (float) pScale, player, modelId, textureId, renderer, entity, disableRot); } } catch (ExecutionException e) { e.printStackTrace(); } } - public static void renderEntityInInventory(int pPosX, int pPosY, int pScale, EntityPlayer player, ResourceLocation modelId, ResourceLocation textureId) { + /** + * {@link com.elfmcys.yesstevemodel.client.gui.button.TextureButton#renderWidget(Minecraft, int, int, float)} + */ + @SuppressWarnings("JavadocReference") + public static void renderTextureButtonEntity(int pPosX, int pPosY, int pScale, EntityPlayer player, ResourceLocation modelId, ResourceLocation textureId) { renderEntityInInventory(pPosX, pPosY, pScale, player, modelId, textureId, entity -> { if (entity.hasPreviewAnimation()) { entity.clearPreviewAnimation(); } - }); + }, false); } private static void renderModel( double pPosX, double pPosY, float pScale, EntityPlayer player, ResourceLocation modelId, ResourceLocation textureId, - GeoReplacedEntityRenderer renderer, CustomPlayerEntity entity + GeoReplacedEntityRenderer renderer, CustomPlayerEntity entity, + boolean disableRot ) { entity.setMainModel(ModelIdUtil.getMainId(modelId)); entity.setTexture(textureId); @@ -279,18 +291,21 @@ private static void renderModel( GlStateManager.translate((float) pPosX, (float) pPosY, 1050.0F); GlStateManager.scale(1.0F, 1.0F, -1.0F); - GlStateManager.translate(0.0D, 0.0D, 1000.0D); + GlStateManager.translate(0.0D, disableRot ? 5.5D : 0.0D, 1000.0D); GlStateManager.scale(pScale, pScale, pScale); GlStateManager.rotate(180.0F, 0, 0, 1); rotateAndEnableLighting(); - float xp = -10; + float xp = disableRot ? 0.0F : -10.0F; GlStateManager.rotate(xp, 1, 0, 0); float yBodyRot = player.renderYawOffset; + float yBodyRotO = player.prevRenderYawOffset; float yRot = player.rotationYaw; + float yRotO = player.prevRotationYaw; float xRot = player.rotationPitch; - float yHeadRotO = player.prevRotationYawHead; + float xRotO = player.prevRotationPitch; float yHeadRot = player.rotationYawHead; + float yHeadRotO = player.prevRotationYawHead; ItemStack[] itemStacks = new ItemStack[EntityEquipmentSlot.values().length]; int i = 0; @@ -306,11 +321,21 @@ private static void renderModel( i++; } - player.renderYawOffset = 200; - player.rotationYaw = 180; - player.rotationPitch = 0; + float renderYRot = disableRot ? 180.0F : 200.0F; + player.renderYawOffset = renderYRot; + player.prevRenderYawOffset = renderYRot; + player.rotationYaw = renderYRot; + player.prevRotationYaw = renderYRot; + player.rotationPitch = 0.0F; + player.prevRotationPitch = 0.0F; player.rotationYawHead = player.rotationYaw; player.prevRotationYawHead = player.rotationYaw; + if (player.getRidingEntity() instanceof EntityLivingBase vehicle) { + float vehicleYRot = vehicle.rotationYaw; + GlStateManager.rotate(vehicleYRot - renderYRot, 0, 1, 0); + player.rotationYawHead = vehicleYRot; + player.prevRotationYawHead = vehicleYRot; + } RenderManager dispatcher = Minecraft.getMinecraft().getRenderManager(); xp = 180.0F - xp; @@ -320,10 +345,13 @@ private static void renderModel( dispatcher.setRenderShadow(true); player.renderYawOffset = yBodyRot; + player.prevRenderYawOffset = yBodyRotO; player.rotationYaw = yRot; + player.prevRotationYaw = yRotO; player.rotationPitch = xRot; - player.prevRotationYawHead = yHeadRotO; + player.prevRotationPitch = xRotO; player.rotationYawHead = yHeadRot; + player.prevRotationYawHead = yHeadRotO; i = 0; for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { diff --git a/src/main/resources/assets/yes_steve_model/builtin/default/arm.animation.json b/src/main/resources/assets/yes_steve_model/builtin/default/arm.animation.json index 81d00d35..57d74788 100644 --- a/src/main/resources/assets/yes_steve_model/builtin/default/arm.animation.json +++ b/src/main/resources/assets/yes_steve_model/builtin/default/arm.animation.json @@ -2384,7 +2384,7 @@ }, "RightForeArm": { "rotation": { - "0.0": ["v.qh?0:-45", "v.qh?180", 0], + "0.0": ["v.qh?0:-45", "v.qh=v.qh==null?180:v.qh", 0], "0.0833": { "pre": ["v.qh?0:-15", "v.qh?180:0", 0], "post": ["v.qh?0:-15", "v.qh?180:0", 0], diff --git a/src/main/resources/assets/yes_steve_model/builtin/default/background.png b/src/main/resources/assets/yes_steve_model/builtin/default/background.png new file mode 100644 index 00000000..540bae4b Binary files /dev/null and b/src/main/resources/assets/yes_steve_model/builtin/default/background.png differ diff --git a/src/main/resources/assets/yes_steve_model/builtin/default/foreground.png b/src/main/resources/assets/yes_steve_model/builtin/default/foreground.png new file mode 100644 index 00000000..deb2e7f5 Binary files /dev/null and b/src/main/resources/assets/yes_steve_model/builtin/default/foreground.png differ diff --git a/src/main/resources/assets/yes_steve_model/builtin/default/info.json b/src/main/resources/assets/yes_steve_model/builtin/default/info.json index 76d7a2f8..e43f237c 100644 --- a/src/main/resources/assets/yes_steve_model/builtin/default/info.json +++ b/src/main/resources/assets/yes_steve_model/builtin/default/info.json @@ -8,5 +8,9 @@ "星屑海螺" ], "license": "CC 0", - "free": true + "free": true, + "gui_background": "background.png", + "gui_foreground": "foreground.png", + "preview_animation": "gui", + "disable_preview_rotation": true } \ No newline at end of file diff --git a/src/main/resources/assets/yes_steve_model/builtin/default/main.animation.json b/src/main/resources/assets/yes_steve_model/builtin/default/main.animation.json index 93ab6d27..ef4ab24b 100644 --- a/src/main/resources/assets/yes_steve_model/builtin/default/main.animation.json +++ b/src/main/resources/assets/yes_steve_model/builtin/default/main.animation.json @@ -1,6 +1,15 @@ { "format_version": "1.8.0", "animations": { + "gui": { + "loop": true, + "bones": { + "MAllBody": { + "position": [0, -22, 0], + "scale": 2 + } + } + }, "idle": { "loop": true, "animation_length": 3, @@ -5264,14 +5273,14 @@ }, "MAllBody": { "rotation": { - "0.0": ["v.elytra?-v.L6_P00", 0, 0], - "0.01": ["v.elytra?-v.L6_P10", 0, 0] + "0.0": ["v.elytra=v.elytra==null?-v.L6_P00:v.elytra", 0, 0], + "0.01": ["v.elytra=v.elytra==null?-v.L6_P10:v.elytra", 0, 0] } }, "AllBody": { "rotation": { - "0.0": [0, "v.elytra?1.5*v.L6_P0-0.4*v.L4_P0", "v.elytra?0.6*v.L6_P0"], - "0.01": [0, "v.elytra?1.5*v.L6_P1-0.4*v.L4_P1", "v.elytra?0.6*v.L6_P1"] + "0.0": [0, "v.elytra=v.elytra==null?1.5*v.L6_P0-0.4*v.L4_P0:v.elytra", "v.elytra=v.elytra==null?0.6*v.L6_P0:v.elytra"], + "0.01": [0, "v.elytra=v.elytra==null?1.5*v.L6_P1-0.4*v.L4_P1:v.elytra", "v.elytra=v.elytra==null?0.6*v.L6_P1:v.elytra"] } } }, diff --git a/src/main/resources/assets/yes_steve_model/builtin/wine_fox/arm.animation.json b/src/main/resources/assets/yes_steve_model/builtin/wine_fox/arm.animation.json index 666c2663..933e6301 100644 --- a/src/main/resources/assets/yes_steve_model/builtin/wine_fox/arm.animation.json +++ b/src/main/resources/assets/yes_steve_model/builtin/wine_fox/arm.animation.json @@ -2388,7 +2388,7 @@ }, "RightForeArm": { "rotation": { - "0.0": ["v.qh?0:-45", "v.qh?180", 0], + "0.0": ["v.qh?0:-45", "v.qh=v.qh==null?180:v.qh", 0], "0.0833": { "pre": ["v.qh?0:-15", "v.qh?180:0", 0], "post": ["v.qh?0:-15", "v.qh?180:0", 0], diff --git a/src/main/resources/assets/yes_steve_model/lang/en_us.lang b/src/main/resources/assets/yes_steve_model/lang/en_us.lang index 90db13ae..06ace79b 100644 --- a/src/main/resources/assets/yes_steve_model/lang/en_us.lang +++ b/src/main/resources/assets/yes_steve_model/lang/en_us.lang @@ -7,6 +7,7 @@ gui.yes_steve_model.auth_models=Auth Models gui.yes_steve_model.star_models=Star Models gui.yes_steve_model.config=Open Config GUI gui.yes_steve_model.download=Open Download GUI +gui.yes_steve_model.show_model_id_first=Show Model ID First gui.yes_steve_model.search=Search models... gui.yes_steve_model.model.authors=§2§l▌ §3Authors: %s gui.yes_steve_model.model.license=§2§l▌ §3License: %s @@ -420,6 +421,8 @@ config.yes_steve_model.general.disable_self_hands=Disable Self Hands config.yes_steve_model.general.disable_self_hands.tooltip=Prevents rendering of self player's hand config.yes_steve_model.general.disable_arrows_model=Disable Arrows Model config.yes_steve_model.general.disable_arrows_model.tooltip=Prevents rendering of arrows model +config.yes_steve_model.general.show_model_id_first=Show Model Id First +config.yes_steve_model.general.show_model_id_first.tooltip=Whether to display model ID first in the model selection screen, instead of the model name filled in by the model author. config.yes_steve_model.general.default_model_id=Default Model Id config.yes_steve_model.general.default_model_id.tooltip=The default model ID when a player first enters the game config.yes_steve_model.general.default_model_texture=Default Model Texture diff --git a/src/main/resources/assets/yes_steve_model/lang/zh_cn.lang b/src/main/resources/assets/yes_steve_model/lang/zh_cn.lang index cd110624..d817ee5f 100644 --- a/src/main/resources/assets/yes_steve_model/lang/zh_cn.lang +++ b/src/main/resources/assets/yes_steve_model/lang/zh_cn.lang @@ -7,6 +7,7 @@ gui.yes_steve_model.auth_models=授权模型 gui.yes_steve_model.star_models=收藏模型 gui.yes_steve_model.config=打开配置界面 gui.yes_steve_model.download=打开下载界面 +gui.yes_steve_model.show_model_id_first=优先显示模型 ID gui.yes_steve_model.search=搜索模型…… gui.yes_steve_model.model.authors=§2§l▌ §3作者:%s gui.yes_steve_model.model.license=§2§l▌ §3协议:%s @@ -420,6 +421,8 @@ config.yes_steve_model.general.disable_self_hands=禁用自身手臂 config.yes_steve_model.general.disable_self_hands.tooltip=阻止渲染玩家自身手臂 config.yes_steve_model.general.disable_arrows_model=禁用箭矢模型 config.yes_steve_model.general.disable_arrows_model.tooltip=阻止渲染自定义箭模型 +config.yes_steve_model.general.show_model_id_first=优先显示模型 ID +config.yes_steve_model.general.show_model_id_first.tooltip=在模型选择界面优先显示模型 ID,而不是模型作者填入的模型名 config.yes_steve_model.general.default_model_id=默认模型 ID config.yes_steve_model.general.default_model_id.tooltip=玩家首次进入游戏时的默认模型 ID config.yes_steve_model.general.default_model_texture=默认模型材质