From 53e9a1f9dad68d1ac1cc7822cf589a0fbd89a675 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 11 Apr 2023 17:16:21 +0200 Subject: [PATCH] Add some compatibility for unicopia --- .../com/minelittlepony/api/model/IPart.java | 19 +++++++++++++++++++ .../api/model/ModelAttributes.java | 2 +- .../client/model/ClientPonyModel.java | 2 ++ .../client/render/LevitatingItemRenderer.java | 17 +++++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/api/model/IPart.java b/src/main/java/com/minelittlepony/api/model/IPart.java index 7e2239da..4e0216b4 100644 --- a/src/main/java/com/minelittlepony/api/model/IPart.java +++ b/src/main/java/com/minelittlepony/api/model/IPart.java @@ -3,6 +3,8 @@ package com.minelittlepony.api.model; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.math.MatrixStack; +import java.util.UUID; + public interface IPart { /** * Sets the model's various rotation angles. @@ -11,6 +13,13 @@ public interface IPart { } + @Deprecated + default void setRotationAndAngles(boolean goingFast, UUID interpolatorId, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) { + Compat.attributes.isGoingFast = goingFast; + Compat.attributes.interpolatorId = interpolatorId; + setPartAngles(Compat.attributes, limbAngle, limbSpeed, bodySwing, animationProgress); + } + /** * Renders this model component. */ @@ -22,4 +31,14 @@ public interface IPart { default void setVisible(boolean visible, ModelAttributes attributes) { } + + @Deprecated + default void setVisible(boolean visible) { + setVisible(visible, Compat.attributes); + } + + @Deprecated + class Compat { + public static ModelAttributes attributes = new ModelAttributes(); + } } diff --git a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java index 6a4dc40e..e49c4027 100644 --- a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java +++ b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java @@ -87,7 +87,7 @@ public class ModelAttributes { * Unique id of the interpolator used for this model. * Usually the UUID of the entity being rendered. */ - private UUID interpolatorId = UUID.randomUUID(); + UUID interpolatorId = UUID.randomUUID(); /** * The actual, visible height of this model when rendered. diff --git a/src/main/java/com/minelittlepony/client/model/ClientPonyModel.java b/src/main/java/com/minelittlepony/client/model/ClientPonyModel.java index 6b040c65..a80607a6 100644 --- a/src/main/java/com/minelittlepony/client/model/ClientPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/ClientPonyModel.java @@ -9,6 +9,7 @@ import net.minecraft.util.Hand; import org.jetbrains.annotations.Nullable; import com.minelittlepony.api.model.ModelAttributes; +import com.minelittlepony.api.model.IPart; import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback; import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPonyData; @@ -48,6 +49,7 @@ public abstract class ClientPonyModel extends MsonPlayer @Override public void updateLivingState(T entity, IPony pony, ModelAttributes.Mode mode) { + IPart.Compat.attributes = attributes; child = entity.isBaby(); attributes.updateLivingState(entity, pony, mode); PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, mode); diff --git a/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java b/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java index 0fc2675e..665f4fcb 100644 --- a/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java @@ -6,8 +6,7 @@ import com.minelittlepony.client.util.render.RenderLayerUtil; import org.jetbrains.annotations.Nullable; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.*; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.util.math.MatrixStack; @@ -16,11 +15,23 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.CrossbowItem; import net.minecraft.item.ItemStack; import net.minecraft.screen.PlayerScreenHandler; +import net.minecraft.util.Identifier; import net.minecraft.util.UseAction; import net.minecraft.util.math.RotationAxis; import net.minecraft.world.World; public class LevitatingItemRenderer { + @Deprecated + private static int COLOR; + @Deprecated + public static boolean isEnabled() { + return false; + } + @Deprecated + public static RenderLayer getRenderLayer(Identifier texture) { + return MagicGlow.getColoured(texture, COLOR); + } + private VertexConsumerProvider getProvider(IPony pony, VertexConsumerProvider renderContext) { final int color = pony.metadata().getGlowColor(); return layer -> { @@ -37,6 +48,8 @@ public class LevitatingItemRenderer { IPony pony = IPony.getManager().getPony((PlayerEntity)entity); + COLOR = pony.metadata().getGlowColor(); + matrix.push(); boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic.get() && pony.hasMagic();