diff --git a/gradle.properties b/gradle.properties index 94ebddfb..1d67e849 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,6 +21,6 @@ org.gradle.daemon=false # Dependencies modmenu_version=7.1.0 - kirin_version=1.15.1 - hd_skins_version=6.9.3-beta.2 + kirin_version=1.15.2 + hd_skins_version=6.10.0+1.20 mson_version=1.8.1 diff --git a/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java b/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java index 0005b529..51f80906 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java +++ b/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java @@ -6,7 +6,9 @@ import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPonyManager; import com.minelittlepony.client.IPreviewModel; import com.minelittlepony.client.render.EquineRenderManager; -import com.minelittlepony.hdskins.client.dummy.*; +import com.minelittlepony.hdskins.client.VanillaModels; +import com.minelittlepony.hdskins.client.gui.player.*; +import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins; import java.util.UUID; @@ -33,12 +35,12 @@ class DummyPony extends DummyPlayer implements IPreviewModel, IPonyManager.Force @Override public String getModel() { if (getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType) { - return getTextures().usesThinSkin() ? "slimseapony" : "seapony"; + return VanillaModels.isSlim(getTextures().getSkinVariant()) ? "slimseapony" : "seapony"; } return IPony.getManager() .getPony(this) .metadata() .getRace() - .getModelId(getTextures().usesThinSkin()); + .getModelId(VanillaModels.isSlim(getTextures().getSkinVariant())); } } diff --git a/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java index 76d9259e..05d484cd 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java @@ -3,24 +3,21 @@ package com.minelittlepony.client.hdskins; import com.minelittlepony.api.pony.IPony; import com.minelittlepony.client.GuiPonySettings; import com.minelittlepony.client.MineLittlePony; +import com.minelittlepony.common.client.gui.dimension.Bounds; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.client.gui.sprite.TextureSprite; -import com.minelittlepony.hdskins.client.dummy.PlayerPreview; +import com.minelittlepony.hdskins.client.gui.DualCarouselWidget; import com.minelittlepony.hdskins.client.gui.GuiSkins; import com.minelittlepony.hdskins.server.SkinServerList; import com.minelittlepony.hdskins.profile.SkinType; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import net.minecraft.client.gui.screen.Screen; import net.minecraft.util.Identifier; -import org.lwjgl.glfw.GLFW; - /** * Skin uploading GUI. Usually displayed over the main menu. */ class GuiSkinsMineLP extends GuiSkins { - private static final String[] PANORAMAS = new String[] { "minelittlepony:textures/cubemap/sugarcubecorner", "minelittlepony:textures/cubemap/quillsandsofas", @@ -29,14 +26,24 @@ class GuiSkinsMineLP extends GuiSkins { public GuiSkinsMineLP(Screen parent, SkinServerList servers) { super(parent, servers); + chooser.addSkinChangedEventListener(type -> { + MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); + if (type == SkinType.SKIN) { + IPony.getManager().removePony(previewer.getLocal().getSkins().get(SkinType.SKIN).getId()); + } + }); + uploader.addSkinLoadedEventListener((type, location, profileTexture) -> { + MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); + if (type == SkinType.SKIN) { + IPony.getManager().removePony(location); + } + }); } @Override - public void init() { - super.init(); - + protected void initServerPreviewButtons(Bounds area) { if (!(parent instanceof GuiPonySettings)) { - addButton(new Button(width - 25, height - 90, 20, 20)) + addButton(new Button(area.right() - 20, area.bottom() + 5, 20, 20)) .onClick(sender -> client.setScreen(new GuiPonySettings(this))) .getStyle() .setIcon(new TextureSprite() @@ -45,21 +52,15 @@ class GuiSkinsMineLP extends GuiSkins { .setTextureSize(16, 16) .setSize(16, 16)) .setTooltip("minelp.options.title", 0, 10); + super.initServerPreviewButtons(new Bounds(area.top, area.left, area.width - 25, area.height)); + } else { + super.initServerPreviewButtons(area); } } - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (modifiers == (GLFW.GLFW_MOD_ALT | GLFW.GLFW_MOD_CONTROL) && keyCode == GLFW.GLFW_KEY_R) { - client.reloadResources(); - return true; - } - - return super.keyPressed(keyCode, scanCode, modifiers); - } - @Override - public PlayerPreview createPreviewer() { - return new PonyPreview(); + public DualCarouselWidget createPreviewer() { + return new PonifiedDualCarouselWidget(this); } @Override @@ -68,24 +69,4 @@ class GuiSkinsMineLP extends GuiSkins { return new Identifier(PANORAMAS[i]); } - - @Override - public void onSetLocalSkin(SkinType type) { - super.onSetLocalSkin(type); - - MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); - if (type == SkinType.SKIN) { - previewer.getLocal().ifPresent(local -> IPony.getManager().removePony(local.getTextures().get(SkinType.SKIN).getId())); - } - } - - @Override - public void onSetRemoteSkin(SkinType type, Identifier location, MinecraftProfileTexture profileTexture) { - super.onSetRemoteSkin(type, location, profileTexture); - - MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); - if (type == SkinType.SKIN) { - IPony.getManager().removePony(location); - } - } } diff --git a/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java b/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java new file mode 100644 index 00000000..0a9545bb --- /dev/null +++ b/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java @@ -0,0 +1,65 @@ +package com.minelittlepony.client.hdskins; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.Text; + +import com.minelittlepony.api.pony.*; +import com.minelittlepony.common.client.gui.ITextContext; +import com.minelittlepony.common.client.gui.dimension.Bounds; +import com.minelittlepony.hdskins.client.gui.Carousel; +import com.minelittlepony.hdskins.client.gui.player.DummyPlayer; + +import java.util.List; +import java.util.stream.Collectors; + +class LegendOverlayWidget implements Carousel.Element, ITextContext { + private static final Bounds LEGEND_BLOCK_BOUNDS = new Bounds(0, 0, 10, 10); + + @Override + public void render(DummyPlayer player, DrawContext context, int mouseX, int mouseY) { + IPonyData data = IPony.getManager().getPony(player).metadata(); + int[] index = new int[1]; + data.getTriggerPixels().forEach((key, value) -> { + context.getMatrices().push(); + int i = index[0]++; + int x = 0;//frame.left; + int y = 0/*frame.top*/ + (i * 10 + 20); + context.getMatrices().translate(x, y, 1); + drawLegendBlock(context, 0, 0, 0, mouseX - x, mouseY - y, key, value); + context.getMatrices().pop(); + }); + MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers().draw(); + } + + private void drawLegendBlock(DrawContext context, int index, int x, int y, int mouseX, int mouseY, String key, TriggerPixelType value) { + context.fill(0, 0, LEGEND_BLOCK_BOUNDS.width, LEGEND_BLOCK_BOUNDS.height, 0xFF003333); + context.fill(1, 1, LEGEND_BLOCK_BOUNDS.width - 1, LEGEND_BLOCK_BOUNDS.height - 1, value.getColorCode() | 0xFF000000); + + char symbol = value.name().charAt(0); + if (symbol == '[') { + symbol = key.charAt(0); + } + + context.drawTextWithShadow(getFont(), Text.literal(String.valueOf(symbol).toUpperCase()), 2, 1, 0xFFFFFFFF); + + if (LEGEND_BLOCK_BOUNDS.contains(mouseX, mouseY)) { + List lines = value.getOptions().stream().map(option -> { + boolean selected = value.matches(option); + return Text.literal((selected ? "* " : " ") + option.name()).styled(s -> { + int color = option.getChannelAdjustedColorCode(); + return (color == 0 ? s : s.withColor(color)).withItalic(selected); + }); + }).collect(Collectors.toList()); + + lines.add(0, Text.of(key.toUpperCase() + ": " + value.getHexValue())); + if (lines.size() == 1) { + lines.add(Text.literal(value.name()).styled(s -> { + int color = value.getChannelAdjustedColorCode(); + return color == 0 ? s : s.withColor(value.getColorCode()); + })); + } + context.drawTooltip(getFont(), lines, 2, 10); + } + } +} diff --git a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java index c7428a98..06ca330d 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java +++ b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java @@ -9,9 +9,9 @@ import com.minelittlepony.common.client.gui.ScrollContainer; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.event.ClientReadyCallback; import com.minelittlepony.hdskins.client.*; -import com.minelittlepony.hdskins.client.dummy.DummyPlayer; -import com.minelittlepony.hdskins.client.dummy.PlayerSkins.PlayerSkin; import com.minelittlepony.hdskins.client.gui.GuiSkins; +import com.minelittlepony.hdskins.client.gui.player.DummyPlayer; +import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins.PlayerSkin; import com.minelittlepony.hdskins.profile.SkinType; import com.mojang.authlib.GameProfile; diff --git a/src/main/java/com/minelittlepony/client/hdskins/PonifiedDualCarouselWidget.java b/src/main/java/com/minelittlepony/client/hdskins/PonifiedDualCarouselWidget.java new file mode 100644 index 00000000..ea3b794d --- /dev/null +++ b/src/main/java/com/minelittlepony/client/hdskins/PonifiedDualCarouselWidget.java @@ -0,0 +1,49 @@ +package com.minelittlepony.client.hdskins; + +import net.minecraft.client.world.ClientWorld; +import net.minecraft.util.Identifier; + +import com.minelittlepony.api.pony.meta.*; +import com.minelittlepony.client.render.entity.SeaponyRenderer; +import com.minelittlepony.hdskins.client.gui.DualCarouselWidget; +import com.minelittlepony.hdskins.client.gui.GuiSkins; +import com.minelittlepony.hdskins.client.gui.player.DummyPlayer; +import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins; +import com.minelittlepony.hdskins.client.resources.NativeImageFilters; +import com.minelittlepony.hdskins.client.resources.TextureLoader; +import com.minelittlepony.hdskins.profile.SkinType; + +class PonifiedDualCarouselWidget extends DualCarouselWidget { + + public PonifiedDualCarouselWidget(GuiSkins screen) { + super(screen); + local.addElement(new LegendOverlayWidget()); + remote.addElement(new LegendOverlayWidget()); + } + + @Override + protected DummyPlayer createEntity(ClientWorld world, PlayerSkins textures) { + return new DummyPony(world, textures); + } + + @Override + public Identifier getDefaultSkin(SkinType type, String modelVariant) { + if (type == MineLPHDSkins.seaponySkinType) { + return NativeImageFilters.GREYSCALE.load(SeaponyRenderer.SEAPONY, SeaponyRenderer.SEAPONY, getExclusion()); + } + + Wearable wearable = MineLPHDSkins.wearableTypes.getOrDefault(type, Wearable.NONE); + + if (wearable != Wearable.NONE) { + return NativeImageFilters.GREYSCALE.load(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion()); + } + + return super.getDefaultSkin(type, modelVariant); + } + + @Override + public TextureLoader.Exclusion getExclusion() { + return TriggerPixel::isTriggerPixelCoord; + } + +} diff --git a/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java b/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java deleted file mode 100644 index 0f1d3732..00000000 --- a/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.minelittlepony.client.hdskins; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; - -import org.jetbrains.annotations.Nullable; - -import com.minelittlepony.api.pony.*; -import com.minelittlepony.api.pony.meta.*; -import com.minelittlepony.client.render.entity.SeaponyRenderer; -import com.minelittlepony.common.client.gui.dimension.Bounds; -import com.minelittlepony.hdskins.client.dummy.*; -import com.minelittlepony.hdskins.client.resources.DefaultSkinGenerator; -import com.minelittlepony.hdskins.client.resources.TextureLoader; -import com.minelittlepony.hdskins.profile.SkinType; - -import java.util.List; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -class PonyPreview extends PlayerPreview { - private static final Bounds LEGEND_BLOCK_BOUNDS = new Bounds(0, 0, 10, 10); - - @Override - protected DummyPlayer createEntity(ClientWorld world, PlayerSkins textures) { - return new DummyPony(world, textures); - } - - @Override - public Identifier getDefaultSkin(SkinType type, boolean slim) { - if (type == MineLPHDSkins.seaponySkinType) { - return DefaultSkinGenerator.generateGreyScale(SeaponyRenderer.SEAPONY, SeaponyRenderer.SEAPONY, getExclusion()); - } - - Wearable wearable = MineLPHDSkins.wearableTypes.getOrDefault(type, Wearable.NONE); - - if (wearable != Wearable.NONE) { - return DefaultSkinGenerator.generateGreyScale(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion()); - } - - return super.getDefaultSkin(type, slim); - } - - @Override - protected TextureLoader.Exclusion getExclusion() { - return TriggerPixel::isTriggerPixelCoord; - } - - @Override - public void renderWorldAndPlayer(Optional thePlayer, - Bounds frame, - int horizon, int mouseX, int mouseY, int ticks, float partialTick, float scale, - DrawContext context, @Nullable Consumer postAction) { - super.renderWorldAndPlayer(thePlayer, frame, horizon, mouseX, mouseY, ticks, partialTick, scale, context, postAction); - thePlayer.ifPresent(p -> { - IPonyData data = IPony.getManager().getPony(p).metadata(); - int[] index = new int[1]; - data.getTriggerPixels().forEach((key, value) -> { - context.getMatrices().push(); - int i = index[0]++; - int x = frame.left; - int y = frame.top + (i * 10 + 20); - context.getMatrices().translate(x, y, 1); - drawLegendBlock(context, 0, 0, 0, mouseX - x, mouseY - y, key, value); - context.getMatrices().pop(); - }); - MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers().draw(); - }); - } - - private void drawLegendBlock(DrawContext context, int index, int x, int y, int mouseX, int mouseY, String key, TriggerPixelType value) { - context.fill(0, 0, LEGEND_BLOCK_BOUNDS.width, LEGEND_BLOCK_BOUNDS.height, 0xFF003333); - context.fill(1, 1, LEGEND_BLOCK_BOUNDS.width - 1, LEGEND_BLOCK_BOUNDS.height - 1, value.getColorCode() | 0xFF000000); - - char symbol = value.name().charAt(0); - if (symbol == '[') { - symbol = key.charAt(0); - } - - context.drawTextWithShadow(getFont(), Text.literal(String.valueOf(symbol).toUpperCase()), 2, 1, 0xFFFFFFFF); - - if (LEGEND_BLOCK_BOUNDS.contains(mouseX, mouseY)) { - List lines = value.getOptions().stream().map(option -> { - boolean selected = value.matches(option); - return Text.literal((selected ? "* " : " ") + option.name()).styled(s -> { - int color = option.getChannelAdjustedColorCode(); - return (color == 0 ? s : s.withColor(color)).withItalic(selected); - }); - }).collect(Collectors.toList()); - - lines.add(0, Text.of(key.toUpperCase() + ": " + value.getHexValue())); - if (lines.size() == 1) { - lines.add(Text.literal(value.name()).styled(s -> { - int color = value.getChannelAdjustedColorCode(); - return color == 0 ? s : s.withColor(value.getColorCode()); - })); - } - context.drawTooltip(getFont(), lines, 2, 10); - } - } -} diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/antlers.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/antlers.png new file mode 100644 index 00000000..3eeb6c0e Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/antlers.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/crown.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/crown.png new file mode 100644 index 00000000..5d644d9b Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/crown.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/hat.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/hat.png new file mode 100644 index 00000000..94584914 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/hat.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/muffin.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/muffin.png new file mode 100644 index 00000000..302e9cc1 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/muffin.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_both.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_both.png new file mode 100644 index 00000000..0efdff55 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_both.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_left.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_left.png new file mode 100644 index 00000000..517b5085 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_left.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_right.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_right.png new file mode 100644 index 00000000..f750bcf2 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/saddle_bags_right.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/gui/skin_type/stetson.png b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/stetson.png new file mode 100644 index 00000000..8c9105f3 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/gui/skin_type/stetson.png differ diff --git a/src/main/resources/assets/minelp/textures/gui/skin_type/seapony.png b/src/main/resources/assets/minelp/textures/gui/skin_type/seapony.png new file mode 100644 index 00000000..7c9ec489 Binary files /dev/null and b/src/main/resources/assets/minelp/textures/gui/skin_type/seapony.png differ