diff --git a/build.gradle b/build.gradle index 0e1f956c..df2aeb0c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,8 +4,7 @@ buildscript { } } plugins { - id 'java-library' - id 'fabric-loom' version '1.1-SNAPSHOT' + id 'fabric-loom' version '1.3-SNAPSHOT' id 'maven-publish' id 'com.modrinth.minotaur' version '2.+' id 'org.ajoberstar.reckon' version '0.13.0' @@ -84,7 +83,10 @@ processResources { inputs.property "version", project.version.toString() filesMatching("fabric.mod.json") { - expand "version": project.version.toString() + expand "version": project.version.toString(), + "minecraftVersion": project.minecraft_version_range, + "loaderVersion": ">=${project.loader_version}", + "fabricVersion": ">=${project.fabric_version}" } from 'LICENSE' @@ -113,6 +115,7 @@ modrinth { versionNumber = version.toString() versionName = archivesBaseName + '-' + version changelog = "[Changelog](https://github.com/MineLittlePony/MineLittlePony/releases/tag/${version.toString()})" + loaders = ['fabric', 'quilt'] uploadFile = remapJar outlet.mcVersions().each{ver -> gameVersions.add ver diff --git a/gradle.properties b/gradle.properties index 1d67e849..178cfe38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.20.1 - yarn_mappings=1.20.1+build.9 - loader_version=0.14.21 - fabric_version=0.85.0+1.20.1 + minecraft_version=1.20.2-rc1 + yarn_mappings=1.20.2-rc1+build.2 + loader_version=0.14.22 + fabric_version=0.88.5+1.20.2 # Mod Properties group=com.minelittlepony @@ -15,12 +15,12 @@ org.gradle.daemon=false description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings. # Publishing - minecraft_version_range=>=1.20.0 + minecraft_version_range=>=1.20.2 modrinth_loader_type=fabric modrinth_project_id=JBjInUXM # Dependencies - modmenu_version=7.1.0 - kirin_version=1.15.2 - hd_skins_version=6.10.0+1.20 - mson_version=1.8.1 + modmenu_version=8.0.0-beta.1 + kirin_version=1.16.0-beta.1+1.20.2 + hd_skins_version=6.11.0-beta.2+1.20.2 + mson_version=1.9.0-beta.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e..59bc51a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java b/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java index bdd4b331..1c8e6b61 100644 --- a/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java +++ b/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java @@ -1,20 +1,40 @@ package com.minelittlepony.api.pony; +import net.minecraft.client.util.DefaultSkinHelper; +import net.minecraft.client.util.SkinTextures; import net.minecraft.util.Identifier; -import java.util.HashMap; -import java.util.Map; +import com.minelittlepony.api.pony.meta.Race; + +import java.util.*; public final class DefaultPonySkinHelper { public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png"); - private static final Map SKINS = new HashMap<>(); + private static final Map SKINS = new HashMap<>(); - public static Identifier getPonySkin(Identifier original) { - return SKINS.computeIfAbsent(original, DefaultPonySkinHelper::computePonySkin); + public static SkinTextures getTextures(SkinTextures original) { + return SKINS.computeIfAbsent(original, o -> { + return new SkinTextures( + new Identifier("minelittlepony", original.texture().getPath().replace(".png", "_pony.png")), + null, + null, + null, + original.model(), + false + ); + }); } - private static Identifier computePonySkin(Identifier original) { - return new Identifier("minelittlepony", original.getPath().replace(".png", "_pony.png")); + public static String getModelType(UUID id) { + SkinTextures textures = DefaultSkinHelper.getTexture(id); + return getModelType(IPony.getManager().getPony(textures.texture(), id).race(), textures.model()); + } + + public static String getModelType(Race race, SkinTextures.Model armShape) { + if (race.isHuman()) { + return armShape.getName(); + } + return (armShape == SkinTextures.Model.SLIM) ? armShape.getName() + race.name().toLowerCase(Locale.ROOT) : race.name().toLowerCase(Locale.ROOT); } } diff --git a/src/main/java/com/minelittlepony/api/pony/meta/Race.java b/src/main/java/com/minelittlepony/api/pony/meta/Race.java index 0f244389..9352b694 100644 --- a/src/main/java/com/minelittlepony/api/pony/meta/Race.java +++ b/src/main/java/com/minelittlepony/api/pony/meta/Race.java @@ -2,8 +2,7 @@ package com.minelittlepony.api.pony.meta; import com.minelittlepony.api.pony.TriggerPixelType; -import java.util.Arrays; -import java.util.List; +import java.util.*; public enum Race implements TriggerPixelType { HUMAN (0x000000, false, false), @@ -73,11 +72,4 @@ public enum Race implements TriggerPixelType { public int getColorCode() { return triggerPixel; } - - public String getModelId(boolean isSlim) { - if (isHuman()) { - return isSlim ? "slim" : "default"; - } - return isSlim ? "slim" + name().toLowerCase() : name().toLowerCase(); - } } diff --git a/src/main/java/com/minelittlepony/client/GuiPonySettings.java b/src/main/java/com/minelittlepony/client/GuiPonySettings.java index 37cc980c..81402dae 100644 --- a/src/main/java/com/minelittlepony/client/GuiPonySettings.java +++ b/src/main/java/com/minelittlepony/client/GuiPonySettings.java @@ -6,7 +6,6 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.*; import com.minelittlepony.client.render.MobRenderers; -import com.minelittlepony.client.render.PonyRenderDispatcher; import com.minelittlepony.client.settings.ClientPonyConfig; import com.minelittlepony.common.client.gui.GameGui; import com.minelittlepony.common.client.gui.ScrollContainer; @@ -118,7 +117,7 @@ public class GuiPonySettings extends GameGui { .onChange(i == config.horsieMode ? (v -> { v = ((Setting)i).set(v); - PonyRenderDispatcher.getInstance().initialise(MinecraftClient.getInstance().getEntityRenderDispatcher(), true); + MineLittlePony.getInstance().getRenderDispatcher().initialise(MinecraftClient.getInstance().getEntityRenderDispatcher(), true); return v; }) : (Setting)i) .setEnabled(enabled); @@ -189,10 +188,10 @@ public class GuiPonySettings extends GameGui { } @Override - public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { - renderBackground(context); - super.render(context, mouseX, mouseY, partialTicks); - content.render(context, mouseX, mouseY, partialTicks); + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + renderBackground(context, mouseX, mouseY, tickDelta); + super.render(context, mouseX, mouseY, tickDelta); + content.render(context, mouseX, mouseY, tickDelta); } @Override diff --git a/src/main/java/com/minelittlepony/client/MineLittlePony.java b/src/main/java/com/minelittlepony/client/MineLittlePony.java index 5c245808..1ed94643 100644 --- a/src/main/java/com/minelittlepony/client/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/client/MineLittlePony.java @@ -40,14 +40,14 @@ public class MineLittlePony implements ClientModInitializer { public static final Logger logger = LogManager.getLogger("MineLittlePony"); - private final PonyRenderDispatcher renderManager = PonyRenderDispatcher.getInstance(); - private ClientPonyConfig config; private PonyManager ponyManager; private VariatedTextureSupplier variatedTextures; private final KeyBinding keyBinding = new KeyBinding("key.minelittlepony.settings", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_F9, "key.categories.misc"); + private final PonyRenderDispatcher renderDispatcher = new PonyRenderDispatcher(); + private boolean hasHdSkins; private boolean hasModMenu; @@ -82,7 +82,9 @@ public class MineLittlePony implements ClientModInitializer { // general events ClientReadyCallback.Handler.register(); ClientTickEvents.END_CLIENT_TICK.register(this::onTick); - ClientReadyCallback.EVENT.register(this::onClientReady); + ClientReadyCallback.EVENT.register(client -> { + renderDispatcher.initialise(client.getEntityRenderDispatcher(), false); + }); ScreenInitCallback.EVENT.register(this::onScreenInit); config.load(); @@ -93,10 +95,6 @@ public class MineLittlePony implements ClientModInitializer { FabricLoader.getInstance().getEntrypoints("minelittlepony", ClientModInitializer.class).forEach(ClientModInitializer::onInitializeClient); } - private void onClientReady(MinecraftClient client) { - renderManager.initialise(client.getEntityRenderDispatcher(), false); - } - private void onTick(MinecraftClient client) { boolean inGame = client.world != null && client.player != null && client.currentScreen == null; @@ -148,5 +146,12 @@ public class MineLittlePony implements ClientModInitializer { public VariatedTextureSupplier getVariatedTextures() { return variatedTextures; } + + /** + * Gets the static pony render manager responsible for all entity renderers. + */ + public PonyRenderDispatcher getRenderDispatcher() { + return renderDispatcher; + } } diff --git a/src/main/java/com/minelittlepony/client/PonyBounds.java b/src/main/java/com/minelittlepony/client/PonyBounds.java index ea0fde43..7f75e7b2 100644 --- a/src/main/java/com/minelittlepony/client/PonyBounds.java +++ b/src/main/java/com/minelittlepony/client/PonyBounds.java @@ -31,7 +31,7 @@ public class PonyBounds { float delta = MinecraftClient.getInstance().getTickDelta(); Entity vehicle = entity.getVehicle(); - double vehicleOffset = vehicle == null ? 0 : vehicle.getHeight() - vehicle.getMountedHeightOffset(); + double vehicleOffset = vehicle == null ? 0 : vehicle.getHeight() - entity.getRidingOffset(vehicle); return new Vec3d( MathHelper.lerp(delta, entity.prevX, entity.getX()), diff --git a/src/main/java/com/minelittlepony/client/SkinsProxy.java b/src/main/java/com/minelittlepony/client/SkinsProxy.java index 69470f60..2f7d6d42 100644 --- a/src/main/java/com/minelittlepony/client/SkinsProxy.java +++ b/src/main/java/com/minelittlepony/client/SkinsProxy.java @@ -4,7 +4,6 @@ import com.minelittlepony.common.client.gui.ScrollContainer; import com.minelittlepony.common.client.gui.Tooltip; import com.minelittlepony.common.client.gui.element.Button; import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import java.util.Optional; import java.util.Set; @@ -25,15 +24,7 @@ public class SkinsProxy { @Nullable public Identifier getSkinTexture(GameProfile profile) { PlayerSkinProvider skins = MinecraftClient.getInstance().getSkinProvider(); - - @Nullable - MinecraftProfileTexture texture = skins.getTextures(profile).get(MinecraftProfileTexture.Type.SKIN); - - if (texture == null) { - return null; - } - - return skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN); + return skins.getSkinTextures(profile).texture(); } public void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) { diff --git a/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java b/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java index 51f80906..3a0dcebf 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java +++ b/src/main/java/com/minelittlepony/client/hdskins/DummyPony.java @@ -2,11 +2,9 @@ package com.minelittlepony.client.hdskins; import net.minecraft.client.world.ClientWorld; -import com.minelittlepony.api.pony.IPony; -import com.minelittlepony.api.pony.IPonyManager; +import com.minelittlepony.api.pony.*; import com.minelittlepony.client.IPreviewModel; import com.minelittlepony.client.render.EquineRenderManager; -import com.minelittlepony.hdskins.client.VanillaModels; import com.minelittlepony.hdskins.client.gui.player.*; import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins; @@ -31,16 +29,4 @@ class DummyPony extends DummyPlayer implements IPreviewModel, IPonyManager.Force public boolean isSubmergedInWater() { return getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType || super.isSubmergedInWater(); } - - @Override - public String getModel() { - if (getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType) { - return VanillaModels.isSlim(getTextures().getSkinVariant()) ? "slimseapony" : "seapony"; - } - return IPony.getManager() - .getPony(this) - .metadata() - .getRace() - .getModelId(VanillaModels.isSlim(getTextures().getSkinVariant())); - } } diff --git a/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java b/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java index ed6f8a6a..233b996e 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java +++ b/src/main/java/com/minelittlepony/client/hdskins/LegendOverlayWidget.java @@ -1,6 +1,5 @@ package com.minelittlepony.client.hdskins; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; diff --git a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java index 06ca330d..16cf620c 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java +++ b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java @@ -118,13 +118,9 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer { @Override public Identifier getSkinTexture(GameProfile profile) { - - Identifier skin = HDSkins.getInstance().getProfileRepository().getTextures(profile).get(SkinType.SKIN); - - if (skin != null) { - return skin; - } - - return super.getSkinTexture(profile); + return HDSkins.getInstance().getProfileRepository() + .getNow(profile) + .getSkin(SkinType.SKIN) + .orElseGet(() -> super.getSkinTexture(profile)); } } diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java b/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java index c76f05be..93d4a425 100644 --- a/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java +++ b/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java @@ -56,7 +56,7 @@ abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implem if (hasVehicle()) { value += getVehicle().getEyeHeight(getVehicle().getPose()); - value -= getVehicle().getMountedHeightOffset(); + value -= getRidingOffset(getVehicle()); } return Math.max(value, 0.1F); diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinDefaultSkinHelper.java b/src/main/java/com/minelittlepony/client/mixin/MixinDefaultSkinHelper.java index 5cb4758f..e25887de 100644 --- a/src/main/java/com/minelittlepony/client/mixin/MixinDefaultSkinHelper.java +++ b/src/main/java/com/minelittlepony/client/mixin/MixinDefaultSkinHelper.java @@ -2,11 +2,12 @@ package com.minelittlepony.client.mixin; import com.minelittlepony.api.config.PonyLevel; import com.minelittlepony.api.pony.DefaultPonySkinHelper; -import com.minelittlepony.api.pony.IPony; import com.minelittlepony.client.MineLittlePony; import net.minecraft.client.util.DefaultSkinHelper; +import net.minecraft.client.util.SkinTextures; import net.minecraft.util.Identifier; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,28 +22,16 @@ abstract class MixinDefaultSkinHelper { cancellable = true) private static void onGetTexture(CallbackInfoReturnable cir) { if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) { - cir.setReturnValue(DefaultPonySkinHelper.getPonySkin(cir.getReturnValue())); + cir.setReturnValue(DefaultPonySkinHelper.STEVE); } } - @Inject(method = "getTexture(Ljava/util/UUID;)Lnet/minecraft/util/Identifier;", + @Inject(method = "getTexture(Ljava/util/UUID;)Lnet/minecraft/client/util/SkinTextures;", at = @At("RETURN"), cancellable = true) - private static void onGetTexture(UUID uuid, CallbackInfoReturnable cir) { + private static void onGetTexture(UUID uuid, CallbackInfoReturnable cir) { if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) { - cir.setReturnValue(DefaultPonySkinHelper.getPonySkin(cir.getReturnValue())); - } - } - - @Inject(method = "getModel(Ljava/util/UUID;)Ljava/lang/String;", - at = @At("RETURN"), - cancellable = true) - private static void onGetModel(UUID uuid, CallbackInfoReturnable cir) { - if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) { - cir.setReturnValue(IPony.getManager() - .getPony(DefaultSkinHelper.getTexture(uuid), uuid) - .race() - .getModelId("slim".equalsIgnoreCase(cir.getReturnValue()))); + cir.setReturnValue(DefaultPonySkinHelper.getTextures(cir.getReturnValue())); } } } diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/client/mixin/MixinEntityRenderDispatcher.java deleted file mode 100644 index 0f9293cd..00000000 --- a/src/main/java/com/minelittlepony/client/mixin/MixinEntityRenderDispatcher.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.minelittlepony.client.mixin; - -import com.minelittlepony.api.pony.IPony; -import com.minelittlepony.client.IPreviewModel; - -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.entity.Entity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(EntityRenderDispatcher.class) -abstract class MixinEntityRenderDispatcher { - @Redirect( - method = "getRenderer(Lnet/minecraft/entity/Entity;)Lnet/minecraft/client/render/entity/EntityRenderer;", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getModel()Ljava/lang/String;")) - private String getPlayerModel(AbstractClientPlayerEntity player, Entity entity) { - if (player instanceof IPreviewModel) { - return player.getModel(); - } - return IPony.getManager() - .getPony(player) - .race() - .getModelId(player.getModel().contains("slim")); - } -} diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinHeldItemRenderer.java b/src/main/java/com/minelittlepony/client/mixin/MixinHeldItemRenderer.java index b78e656e..aa3d4c54 100644 --- a/src/main/java/com/minelittlepony/client/mixin/MixinHeldItemRenderer.java +++ b/src/main/java/com/minelittlepony/client/mixin/MixinHeldItemRenderer.java @@ -4,7 +4,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import com.minelittlepony.client.render.PonyRenderDispatcher; +import com.minelittlepony.client.MineLittlePony; import org.jetbrains.annotations.Nullable; @@ -42,6 +42,6 @@ abstract class MixinHeldItemRenderer { VertexConsumerProvider renderContext, @Nullable World world, int lightUv, int overlayUv, int posLong) { - PonyRenderDispatcher.getInstance().getMagicRenderer().renderItem(target, entity, item, transform, left, stack, renderContext, world, lightUv, posLong); + MineLittlePony.getInstance().getRenderDispatcher().getMagicRenderer().renderItem(target, entity, item, transform, left, stack, renderContext, world, lightUv, posLong); } } diff --git a/src/main/java/com/minelittlepony/client/pony/PonyManager.java b/src/main/java/com/minelittlepony/client/pony/PonyManager.java index e9d86b30..86d8747c 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyManager.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyManager.java @@ -6,7 +6,6 @@ import com.minelittlepony.api.config.PonyLevel; import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPonyManager; import com.minelittlepony.client.MineLittlePony; -import com.minelittlepony.client.render.PonyRenderDispatcher; import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer; import org.jetbrains.annotations.Nullable; @@ -65,7 +64,7 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa } if (entity instanceof LivingEntity living) { - return Optional.ofNullable(PonyRenderDispatcher.getInstance().getPonyRenderer(living)).map(d -> d.getEntityPony(living)); + return Optional.ofNullable(MineLittlePony.getInstance().getRenderDispatcher().getPonyRenderer(living)).map(d -> d.getEntityPony(living)); } return Optional.empty(); @@ -76,19 +75,19 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa Identifier skin = getSkin(player); UUID uuid = player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId(); - if (skin == null) { - if (config.ponyLevel.get() == PonyLevel.PONIES) { - return getBackgroundPony(uuid); + if (skin != null) { + if (player instanceof IPonyManager.ForcedPony) { + return getPony(skin); } - return getAsDefaulted(getPony(DefaultSkinHelper.getTexture(uuid))); + return getPony(skin, uuid); } - if (player instanceof IPonyManager.ForcedPony) { - return getPony(skin); + if (config.ponyLevel.get() == PonyLevel.PONIES) { + return getBackgroundPony(uuid); } - return getPony(skin, uuid); + return getAsDefaulted(getPony(DefaultSkinHelper.getTexture(uuid).texture())); } @Override @@ -104,7 +103,7 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa @Override public IPony getBackgroundPony(UUID uuid) { - return getAsDefaulted(getPony(MineLittlePony.getInstance().getVariatedTextures().get(BACKGROUND_PONIES, uuid).orElse(DefaultSkinHelper.getTexture(uuid)))); + return getAsDefaulted(getPony(MineLittlePony.getInstance().getVariatedTextures().get(BACKGROUND_PONIES, uuid).orElse(DefaultSkinHelper.getTexture(uuid).texture()))); } private IPony getAsDefaulted(IPony pony) { @@ -121,7 +120,7 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa return null; } if (player instanceof AbstractClientPlayerEntity) { - return ((AbstractClientPlayerEntity)player).getSkinTexture(); + return ((AbstractClientPlayerEntity)player).method_52814().texture(); } return null; diff --git a/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java b/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java index 2e59b5df..d35d0128 100644 --- a/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java +++ b/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java @@ -79,7 +79,7 @@ public class EquineRenderManager renderer = PonyRenderDispatcher.getInstance().getPonyRenderer(ridingEntity); + IPonyRenderContext renderer = MineLittlePony.getInstance().getRenderDispatcher().getPonyRenderer(ridingEntity); if (renderer != null) { // negate vanilla translations so the rider begins at the ridees feet. diff --git a/src/main/java/com/minelittlepony/client/render/MobRenderers.java b/src/main/java/com/minelittlepony/client/render/MobRenderers.java index 0f4e9aeb..f61a48b4 100644 --- a/src/main/java/com/minelittlepony/client/render/MobRenderers.java +++ b/src/main/java/com/minelittlepony/client/render/MobRenderers.java @@ -83,7 +83,7 @@ public final class MobRenderers { public boolean set(boolean value) { value = option().set(value); - apply(PonyRenderDispatcher.getInstance(), false); + apply(MineLittlePony.getInstance().getRenderDispatcher(), false); return value; } diff --git a/src/main/java/com/minelittlepony/client/render/PonyRenderDispatcher.java b/src/main/java/com/minelittlepony/client/render/PonyRenderDispatcher.java index 547a3a28..1d64fa6e 100644 --- a/src/main/java/com/minelittlepony/client/render/PonyRenderDispatcher.java +++ b/src/main/java/com/minelittlepony/client/render/PonyRenderDispatcher.java @@ -1,7 +1,10 @@ package com.minelittlepony.client.render; +import java.util.Locale; import java.util.function.Function; +import java.util.function.Predicate; +import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.meta.Race; import com.minelittlepony.client.mixin.MixinEntityRenderers; import com.minelittlepony.client.model.IPonyModel; @@ -12,31 +15,25 @@ import org.jetbrains.annotations.Nullable; import com.minelittlepony.mson.api.Mson; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.*; import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.SkinTextures; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; +import net.minecraft.util.Identifier; /** * Render manager responsible for replacing and restoring entity renderers when the client settings change. - * Old values are persisted internally. */ public class PonyRenderDispatcher { - - private static final PonyRenderDispatcher INSTANCE = new PonyRenderDispatcher(); - - /** - * Gets the static pony render manager responsible for all entity renderers. - */ - public static PonyRenderDispatcher getInstance() { - return INSTANCE; - } - private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer(); + public LevitatingItemRenderer getMagicRenderer() { + return magicRenderer; + } + /** * Registers all new player skin types. (currently only pony and slimpony). */ @@ -50,14 +47,18 @@ public class PonyRenderDispatcher { } private void registerPlayerSkin(EntityRenderDispatcher manager, Race race) { - addPlayerSkin(manager, false, race); - addPlayerSkin(manager, true, race); + addPlayerSkin(manager, SkinTextures.Model.SLIM, race); + addPlayerSkin(manager, SkinTextures.Model.WIDE, race); } - private void addPlayerSkin(EntityRenderDispatcher manager, boolean slimArms, Race race) { + private void addPlayerSkin(EntityRenderDispatcher manager, SkinTextures.Model armShape, Race race) { Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer( - race.getModelId(slimArms), - ModelType.getPlayerModel(race).getFactory(slimArms) + new Identifier("minelittlepony", race.name().toLowerCase(Locale.ROOT) + "/" + armShape.getName()), + (Predicate)(player -> { + return IPony.getManager().getPony(player).metadata().getRace() == race + && player.method_52814().model() == armShape; + }), + ModelType.getPlayerModel(race).getFactory(armShape == SkinTextures.Model.SLIM) ); } @@ -79,10 +80,6 @@ public class PonyRenderDispatcher { }); } - public LevitatingItemRenderer getMagicRenderer() { - return magicRenderer; - } - @SuppressWarnings("unchecked") @Nullable public & IPonyModel> IPonyRenderContext getPonyRenderer(@Nullable T entity) { diff --git a/src/main/java/com/minelittlepony/client/render/blockentity/skull/PlayerPonySkull.java b/src/main/java/com/minelittlepony/client/render/blockentity/skull/PlayerPonySkull.java index bbed84e8..95de7b32 100644 --- a/src/main/java/com/minelittlepony/client/render/blockentity/skull/PlayerPonySkull.java +++ b/src/main/java/com/minelittlepony/client/render/blockentity/skull/PlayerPonySkull.java @@ -16,7 +16,6 @@ import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.DefaultSkinHelper; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import net.minecraft.util.Uuids; import net.minecraft.util.math.RotationAxis; import org.jetbrains.annotations.Nullable; @@ -46,7 +45,7 @@ public class PlayerPonySkull implements ISkull { return skin; } - return DefaultSkinHelper.getTexture(Uuids.getUuidFromProfile(profile)); + return DefaultSkinHelper.getTexture(profile).texture(); } return DefaultSkinHelper.getTexture(); diff --git a/src/main/java/com/minelittlepony/client/render/entity/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/AbstractPonyRenderer.java index bae490c9..3b9febd0 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/AbstractPonyRenderer.java @@ -99,7 +99,7 @@ public abstract class AbstractPonyRenderer { return renderContext.getBuffer(RenderLayerUtil .getTexture(layer) diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java index 212e9cf0..a6382f10 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java @@ -85,7 +85,7 @@ public class ArmourFeature & IP } if (stack.getItem() instanceof ArmorItem armor) { - ArmorTrim.getTrim(entity.getWorld().getRegistryManager(), stack).ifPresent(trim -> { + ArmorTrim.getTrim(entity.getWorld().getRegistryManager(), stack, true).ifPresent(trim -> { pony.getArmourModel(stack, layer, ArmourVariant.TRIM) .filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body())) .ifPresent(m -> { @@ -107,7 +107,7 @@ public class ArmourFeature & IP ); return sprite.getTextureSpecificVertexConsumer( - ItemRenderer.getDirectItemGlintConsumer(provider, TexturedRenderLayers.getArmorTrims(), true, glint) + ItemRenderer.getDirectItemGlintConsumer(provider, TexturedRenderLayers.getArmorTrims(trim.getPattern().value().decal()), true, glint) ); } } diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/CapeFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/CapeFeature.java index 83173993..baa08fba 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/CapeFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/CapeFeature.java @@ -25,8 +25,8 @@ public class CapeFeature> public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { M model = getModelWrapper().body(); - if (player.hasSkinTexture() && !player.isInvisible() - && player.isPartVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null + if (!player.isInvisible() + && player.isPartVisible(PlayerModelPart.CAPE) && player.method_52814().capeTexture() != null && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { stack.push(); @@ -64,7 +64,7 @@ public class CapeFeature> stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180)); stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90)); - VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getCapeTexture())); + VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.method_52814().capeTexture())); model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV); stack.pop(); } diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/DJPon3Feature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/DJPon3Feature.java index 5749dce2..936f2053 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/DJPon3Feature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/DJPon3Feature.java @@ -36,7 +36,7 @@ public class DJPon3Feature & IP } protected Identifier getElytraTexture(T entity) { - if (entity instanceof AbstractClientPlayerEntity) { - AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity; + if (entity instanceof AbstractClientPlayerEntity player) { + SkinTextures textures = player.method_52814(); - Identifier result; - - if (player.hasSkinTexture()) { - result = player.getElytraTexture(); - - if (result != null) return result; + if (textures.elytraTexture() != null) { + return textures.elytraTexture(); } - if (player.hasSkinTexture() && player.isPartVisible(PlayerModelPart.CAPE)) { - result = player.getCapeTexture(); - - if (result != null) return result; + if (textures.capeTexture() != null && player.isPartVisible(PlayerModelPart.CAPE)) { + return textures.capeTexture(); } } diff --git a/src/main/java/com/minelittlepony/client/render/entity/npc/textures/PlayerTextureSupplier.java b/src/main/java/com/minelittlepony/client/render/entity/npc/textures/PlayerTextureSupplier.java index a1320ad4..cf28e4cd 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/npc/textures/PlayerTextureSupplier.java +++ b/src/main/java/com/minelittlepony/client/render/entity/npc/textures/PlayerTextureSupplier.java @@ -8,8 +8,8 @@ import org.jetbrains.annotations.Nullable; import com.minelittlepony.api.pony.IPony; import com.minelittlepony.client.SkinsProxy; import com.minelittlepony.util.FunctionUtil; -import com.mojang.authlib.GameProfile; +import java.util.concurrent.CompletableFuture; import java.util.function.Function; public class PlayerTextureSupplier { @@ -25,24 +25,20 @@ public class PlayerTextureSupplier { } static final class Entry { - @Nullable - private GameProfile profile; + private final CompletableFuture profile; Entry(LivingEntity entity) { - SkullBlockEntity.loadProperties(new GameProfile(null, entity.getCustomName().getString()), resolved -> { - profile = resolved; + profile = SkullBlockEntity.fetchProfile(entity.getCustomName().getString()).thenApply(profile -> { + return profile + .map(p -> SkinsProxy.instance.getSkinTexture(p)) + .filter(skin -> !IPony.getManager().getPony(skin).race().isHuman()) + .orElse(null); }); } @Nullable public Identifier getTexture() { - if (profile != null) { - Identifier skin = SkinsProxy.instance.getSkinTexture(profile); - if (skin != null && !IPony.getManager().getPony(skin).race().isHuman()) { - return skin; - } - } - return null; + return profile.getNow(null); } } } diff --git a/src/main/resources/minelp.aw b/src/main/resources/minelp.aw index 7b2e3e2a..7271f6fc 100644 --- a/src/main/resources/minelp.aw +++ b/src/main/resources/minelp.aw @@ -3,9 +3,11 @@ accessible class net/minecraft/client/render/RenderLayer$MultiPhaseP accessible class net/minecraft/client/render/RenderPhase$TextureBase accessible class net/minecraft/client/render/VertexConsumers$Union -accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;ILnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase; -accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;IZZLnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase; +accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;ILnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase; +accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;IZZLnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase; -accessible method net/minecraft/client/render/RenderLayer$MultiPhase getPhases ()Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters; -accessible method net/minecraft/client/render/RenderPhase$TextureBase getId ()Ljava/util/Optional; -accessible field net/minecraft/client/render/RenderLayer$MultiPhaseParameters texture Lnet/minecraft/client/render/RenderPhase$TextureBase; +accessible method net/minecraft/client/render/RenderLayer$MultiPhase getPhases ()Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters; +accessible method net/minecraft/client/render/RenderPhase$TextureBase getId ()Ljava/util/Optional; +accessible field net/minecraft/client/render/RenderLayer$MultiPhaseParameters texture Lnet/minecraft/client/render/RenderPhase$TextureBase; + +accessible method net/minecraft/block/entity/SkullBlockEntity fetchProfile (Ljava/lang/String;)Ljava/util/concurrent/CompletableFuture; \ No newline at end of file diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index edb508ea..ac4aa1d6 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -8,7 +8,6 @@ "IResizeable", "MixinCamera", "MixinDefaultSkinHelper", - "MixinEntityRenderDispatcher", "MixinEntityRenderers", "MixinSkullBlockEntityRenderer", "MixinHeldItemRenderer",