diff --git a/src/main/java/com/minelittlepony/api/model/gear/IGear.java b/src/main/java/com/minelittlepony/api/model/gear/IGear.java index b0509588..1b996317 100644 --- a/src/main/java/com/minelittlepony/api/model/gear/IGear.java +++ b/src/main/java/com/minelittlepony/api/model/gear/IGear.java @@ -2,6 +2,7 @@ package com.minelittlepony.api.model.gear; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.util.Identifier; @@ -9,10 +10,9 @@ import net.minecraft.util.Identifier; import com.minelittlepony.api.model.BodyPart; import com.minelittlepony.api.model.IModel; import com.minelittlepony.api.pony.meta.Wearable; +import com.minelittlepony.client.model.IPonyModel; import com.minelittlepony.client.render.entity.feature.GearFeature; -import org.jetbrains.annotations.Nullable; - import java.util.UUID; import java.util.function.Supplier; @@ -57,32 +57,41 @@ public interface IGear { } /** - * Orients this wearable. + * Applies body transformations for this wearable */ - default void setModelAttributes(IModel model, Entity entity) { - + default & IPonyModel> void transform(M model, MatrixStack matrices) { + BodyPart part = getGearLocation(); + model.transform(part, matrices); + model.getBodyPart(part).rotate(matrices); } + /** * Sets the model's various rotation angles. * * See {@link AbstractPonyMode.setRotationAndAngle} for an explanation of the various parameters. */ - default void pose(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { - + default void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { + setModelAttributes(model, entity); + pose(rainboom, interpolatorId, move, swing, bodySwing, ticks); } + /** + * @deprecated Use pose(model, entity, rainboom, interpolatorId, move, swing, bodySwing, ticks) instead + */ + @Deprecated(forRemoval = true) + default void setModelAttributes(IModel model, Entity entity) { } + + /** + * @deprecated Use pose(model, entity, rainboom, interpolatorId, move, swing, bodySwing, ticks) instead + */ + @Deprecated(forRemoval = true) + default void pose(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { } + /** * Renders this model component. */ void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId); - /** - * Sets whether this part should be rendered. - */ - default void setVisible(boolean visible) { - - } - /** * A render context for instance of IGear. * @@ -102,11 +111,6 @@ public interface IGear { return gear.canRender(model, entity); } - @Nullable - default M getEntityModel() { - return null; - } - /** * Gets the default texture to use for this entity and wearable. * diff --git a/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java b/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java index aecdcc0d..bc72d63f 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java +++ b/src/main/java/com/minelittlepony/client/model/gear/ChristmasHat.java @@ -50,12 +50,7 @@ public class ChristmasHat extends AbstractGear implements PonyModelConstants { } @Override - public void setModelAttributes(IModel model, Entity entity) { - tint = model.getMetadata().getGlowColor(); - } - - @Override - public void pose(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { + public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { float pi = PI * (float) Math.pow(swing, 16); float mve = move * 0.6662f; @@ -65,6 +60,7 @@ public class ChristmasHat extends AbstractGear implements PonyModelConstants { bodySwing += 0.1F; + tint = model.getMetadata().getGlowColor(); left.roll = bodySwing; right.roll = -bodySwing; } diff --git a/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java b/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java index c99084f0..e39e690a 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java +++ b/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java @@ -28,8 +28,6 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants { float dropAmount = 0; - private IModel model; - public SaddleBags(ModelPart tree) { strap = tree.getChild("strap"); leftBag = tree.getChild("left_bag"); @@ -37,18 +35,13 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants { } @Override - public void setModelAttributes(IModel model, Entity entity) { - this.model = model; - + public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { hangLow = false; if (model instanceof IPegasus) { hangLow = model.canFly() && ((IPegasus)model).wingsAreOpen(); } - } - @Override - public void pose(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { float pi = PI * (float) Math.pow(swing, 16); float mve = move * 0.6662f; @@ -68,6 +61,7 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants { rightBag.roll = -bodySwing; dropAmount = hangLow ? 0.15F : 0; + dropAmount = model.getMetadata().getInterpolator(interpolatorId).interpolate("dropAmount", dropAmount, 3); } public void sethangingLow(boolean veryLow) { @@ -76,8 +70,6 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants { @Override public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) { - dropAmount = model.getMetadata().getInterpolator(interpolatorId).interpolate("dropAmount", dropAmount, 3); - stack.push(); stack.translate(0, dropAmount, 0); diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java index 8b1e71f8..79667a98 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java @@ -69,8 +69,7 @@ public class GearFeature & IPon .forEach(entry -> { stack.push(); BodyPart part = entry.gear.getGearLocation(); - model.transform(part, stack); - model.getBodyPart(part).rotate(stack); + entry.gear.transform(model, stack); if (entry.gear instanceof IStackable) { renderStackingOffsets.compute(part, (k, v) -> { @@ -89,13 +88,8 @@ public class GearFeature & IPon } private void renderGear(M model, T entity, IGear gear, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, float limbDistance, float limbAngle, float tickDelta) { - gear.setModelAttributes(model, entity); - gear.pose(model.getAttributes().isGoingFast, entity.getUuid(), limbDistance, limbAngle, model.getWobbleAmount(), tickDelta); - - RenderLayer layer = RenderLayer.getEntityTranslucent(gear.getTexture(entity, getContext())); - - VertexConsumer vertexConsumer = renderContext.getBuffer(layer); - gear.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1, entity.getUuid()); + gear.pose(model, entity, model.getAttributes().isGoingFast, entity.getUuid(), limbDistance, limbAngle, model.getWobbleAmount(), tickDelta); + gear.render(stack, renderContext.getBuffer(RenderLayer.getEntityTranslucent(gear.getTexture(entity, getContext()))), lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1, entity.getUuid()); } static record Entry(IGear gear, Wearable wearable) {}