mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Use RenderList to manage rendering model parts in passes
This commit is contained in:
parent
69a7806ad1
commit
96cfd13b96
20 changed files with 161 additions and 182 deletions
|
@ -18,7 +18,7 @@ public interface IPart extends PonyModelConstants {
|
|||
/**
|
||||
* Renders this model component.
|
||||
*/
|
||||
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId);
|
||||
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes);
|
||||
|
||||
/**
|
||||
* Sets whether this part should be rendered.
|
||||
|
|
|
@ -7,8 +7,11 @@ import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
|
|||
import com.minelittlepony.api.pony.meta.Sizes;
|
||||
import com.minelittlepony.client.model.armour.ArmourWrapper;
|
||||
import com.minelittlepony.client.transform.PonyTransformation;
|
||||
import com.minelittlepony.client.util.render.RenderList;
|
||||
import com.minelittlepony.mson.util.PartUtil;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
@ -27,12 +30,31 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
|
||||
protected final ModelPart neck;
|
||||
|
||||
public final RenderList helmetRenderList;
|
||||
protected final RenderList neckRenderList;
|
||||
public final RenderList headRenderList;
|
||||
protected final RenderList bodyRenderList;
|
||||
protected final RenderList vestRenderList;
|
||||
|
||||
protected final RenderList legsRenderList;
|
||||
protected final RenderList sleevesRenderList;
|
||||
|
||||
protected final RenderList mainRenderList;
|
||||
|
||||
public AbstractPonyModel(ModelPart tree) {
|
||||
super(tree);
|
||||
|
||||
upperTorso = tree.getChild("upper_torso");
|
||||
upperTorsoOverlay = tree.getChild("saddle");
|
||||
neck = tree.getChild("neck");
|
||||
mainRenderList = RenderList.of()
|
||||
.add(withStage(BodyPart.BODY, bodyRenderList = RenderList.of(body, upperTorso).add(body::rotate)))
|
||||
.add(withStage(BodyPart.NECK, neckRenderList = RenderList.of(neck)))
|
||||
.add(withStage(BodyPart.HEAD, headRenderList = RenderList.of(head)))
|
||||
.add(withStage(BodyPart.LEGS, legsRenderList = RenderList.of().add(this::rotateForBody).add(leftArm, rightArm, leftLeg, rightLeg)))
|
||||
.add(withStage(BodyPart.LEGS, sleevesRenderList = RenderList.of().add(this::rotateForBody).add(leftSleeve, rightSleeve, leftPants, rightPants)))
|
||||
.add(withStage(BodyPart.BODY, vestRenderList = RenderList.of(jacket, upperTorsoOverlay)))
|
||||
.add(withStage(BodyPart.HEAD, helmetRenderList = RenderList.of(hat)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,6 +62,32 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
return ArmourWrapper.of(PonyArmourModel::new);
|
||||
}
|
||||
|
||||
protected RenderList forPart(Supplier<IPart> part) {
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
part.get().renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
||||
};
|
||||
}
|
||||
|
||||
protected RenderList forPart(IPart part) {
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
part.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
mainRenderList.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
protected RenderList withStage(BodyPart part, RenderList action) {
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
stack.push();
|
||||
transform(part, stack);
|
||||
action.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the model's various rotation angles.
|
||||
*
|
||||
|
@ -542,68 +590,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
renderStage(BodyPart.BODY, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderBody);
|
||||
renderStage(BodyPart.NECK, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderNeck);
|
||||
renderStage(BodyPart.HEAD, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderHead);
|
||||
renderStage(BodyPart.LEGS, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderLegs);
|
||||
|
||||
renderStage(BodyPart.LEGS, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderSleeves);
|
||||
renderStage(BodyPart.BODY, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderVest);
|
||||
renderStage(BodyPart.HEAD, stack, vertices, overlayUv, lightUv, red, green, blue, alpha, this::renderHelmet);
|
||||
}
|
||||
|
||||
protected void renderStage(BodyPart part, MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, RenderStage action) {
|
||||
stack.push();
|
||||
transform(part, stack);
|
||||
action.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
public void renderHead(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
head.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void renderHelmet(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
hat.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
protected void renderNeck(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
neck.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
body.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
upperTorso.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
body.rotate(stack);
|
||||
}
|
||||
|
||||
protected void renderVest(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
jacket.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
upperTorsoOverlay.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
protected void renderLegs(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
protected void rotateForBody(MatrixStack stack) {
|
||||
if (!sneaking) {
|
||||
body.rotate(stack);
|
||||
}
|
||||
|
||||
leftArm.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightArm.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
leftLeg.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightLeg.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
protected void renderSleeves(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
if (!sneaking) {
|
||||
body.rotate(stack);
|
||||
}
|
||||
|
||||
leftSleeve.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightSleeve.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
leftPants.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightPants.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -629,8 +619,4 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
|
||||
PonyTransformation.forSize(getSize()).transform(this, part, stack);
|
||||
}
|
||||
|
||||
protected interface RenderStage {
|
||||
void accept(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import com.minelittlepony.api.model.IModel;
|
||||
|
@ -25,6 +23,10 @@ public class PonyArmourModel<T extends LivingEntity> extends AbstractPonyModel<T
|
|||
chestPiece = tree.getChild("chestpiece");
|
||||
steveRightLeg = tree.getChild("steve_right_leg");
|
||||
steveLeftLeg = tree.getChild("steve_left_leg");
|
||||
|
||||
bodyRenderList.clear();
|
||||
bodyRenderList.add(body, upperTorso, chestPiece);
|
||||
legsRenderList.add(steveLeftLeg, steveRightLeg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,23 +38,6 @@ public class PonyArmourModel<T extends LivingEntity> extends AbstractPonyModel<T
|
|||
chestPiece.pivotZ = rotationPointZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float limbDistance, float limbAngle, float tickDelta, float alpha) {
|
||||
if (variant == ArmourVariant.LEGACY) {
|
||||
body.render(stack, vertices, overlayUv, lightUv, limbDistance, limbAngle, tickDelta, alpha);
|
||||
upperTorso.render(stack, vertices, overlayUv, lightUv, limbDistance, limbAngle, tickDelta, alpha);
|
||||
} else {
|
||||
chestPiece.render(stack, vertices, overlayUv, lightUv, limbDistance, limbAngle, tickDelta, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLegs(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
super.renderLegs(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
steveLeftLeg.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
steveRightLeg.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariant(ArmourVariant variant) {
|
||||
this.variant = variant;
|
||||
|
@ -108,6 +93,9 @@ public class PonyArmourModel<T extends LivingEntity> extends AbstractPonyModel<T
|
|||
public void showChestplate() {
|
||||
chestPiece.visible = true;
|
||||
neck.visible = true;
|
||||
body.visible = variant == ArmourVariant.LEGACY;
|
||||
upperTorso.visible = variant == ArmourVariant.LEGACY;
|
||||
chestPiece.visible = variant == ArmourVariant.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.minelittlepony.client.model.entity;
|
|||
|
||||
import net.minecraft.entity.mob.WitherSkeletonEntity;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -21,14 +19,10 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> imp
|
|||
|
||||
public SkeleponyModel(ModelPart tree) {
|
||||
super(tree, false);
|
||||
this.vestRenderList.clear();
|
||||
this.sleevesRenderList.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderVest(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) { }
|
||||
|
||||
@Override
|
||||
protected void renderSleeves(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) { }
|
||||
|
||||
@Override
|
||||
public void animateModel(T entity, float move, float swing, float ticks) {
|
||||
isUnicorn = entity.getUuid().getLeastSignificantBits() % 3 != 0;
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.minelittlepony.api.model.IPegasus;
|
|||
import com.minelittlepony.mson.api.ModelContext;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public class AlicornModel<T extends LivingEntity> extends UnicornModel<T> implements IPegasus {
|
||||
|
@ -21,6 +19,7 @@ public class AlicornModel<T extends LivingEntity> extends UnicornModel<T> implem
|
|||
public void init(ModelContext context) {
|
||||
super.init(context);
|
||||
wings = context.findByName("wings");
|
||||
headRenderList.add(forPart(this::getWings).checked(this::canFly));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,15 +36,6 @@ public class AlicornModel<T extends LivingEntity> extends UnicornModel<T> implem
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
super.renderBody(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
|
||||
if (canFly()) {
|
||||
getWings().renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
|
|
|
@ -6,8 +6,6 @@ import com.minelittlepony.client.model.part.PonySnout;
|
|||
import com.minelittlepony.mson.api.ModelContext;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public class EarthPonyModel<T extends LivingEntity> extends AbstractPonyModel<T> {
|
||||
|
@ -30,6 +28,8 @@ public class EarthPonyModel<T extends LivingEntity> extends AbstractPonyModel<T>
|
|||
tail = context.findByName("tail");
|
||||
snout = context.findByName("snout");
|
||||
ears = context.findByName("ears");
|
||||
|
||||
bodyRenderList.add(forPart(tail));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,12 +51,6 @@ public class EarthPonyModel<T extends LivingEntity> extends AbstractPonyModel<T>
|
|||
tail.setRotationAndAngles(attributes.isSwimming || attributes.isGoingFast, attributes.interpolatorId, move, swing, bodySwing * 5, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
super.renderBody(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
tail.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.minelittlepony.api.model.IPegasus;
|
|||
import com.minelittlepony.mson.api.ModelContext;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public class PegasusModel<T extends LivingEntity> extends EarthPonyModel<T> implements IPegasus {
|
||||
|
@ -21,6 +19,7 @@ public class PegasusModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
public void init(ModelContext context) {
|
||||
super.init(context);
|
||||
wings = context.findByName("wings");
|
||||
bodyRenderList.add(forPart(this::getWings));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,12 +33,6 @@ public class PegasusModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
getWings().setRotationAndAngles(attributes.isGoingFast, entity.getUuid(), move, swing, 0, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
super.renderBody(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
getWings().renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.minelittlepony.api.pony.IPony;
|
|||
import com.minelittlepony.client.model.armour.ArmourWrapper;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -38,6 +37,8 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
|||
public void init(ModelContext context) {
|
||||
super.init(context);
|
||||
setVisible(true);
|
||||
bodyRenderList.clear();
|
||||
bodyRenderList.add(body, abdomin).add(body::rotate).add(forPart(tail)).add(leftFin, centerFin, rightFin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,18 +113,6 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
|||
|
||||
@Override
|
||||
public boolean hasMagic() {
|
||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
body.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
abdomin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
body.rotate(stack);
|
||||
|
||||
tail.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
||||
leftFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
centerFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@ import com.minelittlepony.api.model.BodyPart;
|
|||
import com.minelittlepony.api.model.IUnicorn;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.part.UnicornHorn;
|
||||
import com.minelittlepony.client.util.render.RenderList;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Arm;
|
||||
|
||||
|
@ -32,6 +31,10 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
public void init(ModelContext context) {
|
||||
super.init(context);
|
||||
horn = context.findByName("horn");
|
||||
headRenderList.add(RenderList.of().add(head::rotate).add(forPart(horn)).checked(this::hasHorn));
|
||||
this.mainRenderList.add(withStage(BodyPart.HEAD, RenderList.of().add(head::rotate).add((stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
horn.renderMagic(stack, vertices, getMagicColor());
|
||||
})).checked(() -> hasHorn() && hasMagic() && isCasting()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,29 +66,6 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
unicornArmLeft.pitch -= LEG_ROT_X_SNEAK_ADJ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHead(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
super.renderHead(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
|
||||
if (hasHorn()) {
|
||||
head.rotate(stack);
|
||||
horn.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
super.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
|
||||
if (hasHorn() && canCast() && isCasting()) {
|
||||
stack.push();
|
||||
transform(BodyPart.HEAD, stack);
|
||||
head.rotate(stack);
|
||||
horn.renderMagic(stack, vertices, getMagicColor());
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelPart getArm(Arm side) {
|
||||
if (hasMagic() && getArmPoseForSide(side) != ArmPose.EMPTY && MineLittlePony.getInstance().getConfig().tpsmagic.get()) {
|
||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import com.minelittlepony.api.model.IPegasus;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
|
||||
public class BatWings<T extends Model & IPegasus> extends PegasusWings<T> {
|
||||
|
||||
|
@ -16,11 +15,11 @@ public class BatWings<T extends Model & IPegasus> extends PegasusWings<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
stack.push();
|
||||
stack.scale(1.3F, 1.3F, 1.3F);
|
||||
|
||||
super.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, interpolatorId);
|
||||
super.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
||||
|
||||
stack.pop();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.common.util.animation.Interpolator;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
|
@ -87,7 +88,7 @@ public class LionTail implements IPart, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
tail.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.IPegasus;
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
|
@ -83,7 +82,7 @@ public class PegasusWings<T extends Model & IPegasus> implements IPart, MsonMode
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
getLeft().render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
getRight().render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
|
|
@ -5,12 +5,11 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
import com.minelittlepony.mson.api.model.PartBuilder;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PonyEars implements IPart, MsonModel {
|
||||
private ModelPart right;
|
||||
private ModelPart left;
|
||||
|
@ -29,7 +28,7 @@ public class PonyEars implements IPart, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,14 +5,13 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.api.pony.meta.Gender;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
import com.minelittlepony.mson.api.model.PartBuilder;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PonySnout implements IPart, MsonModel {
|
||||
|
||||
private boolean visible = false;
|
||||
|
@ -40,8 +39,7 @@ public class PonySnout implements IPart, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
mare.render(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.api.pony.meta.TailShape;
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
|
@ -98,7 +99,7 @@ public class PonyTail implements IPart, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
stack.push();
|
||||
tail.rotate(stack);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.client.model.part;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
|
@ -45,7 +46,7 @@ public class SeaponyTail implements IPart, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
tailBase.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,15 +8,12 @@ import net.minecraft.client.render.VertexConsumerProvider.Immediate;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import com.minelittlepony.api.model.IPart;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.client.render.MagicGlow;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.mson.api.ModelContext;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class UnicornHorn implements IPart, MsonModel {
|
||||
|
||||
private ModelPart horn;
|
||||
|
@ -35,7 +32,7 @@ public class UnicornHorn implements IPart, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, @Nullable UUID interpolatorId) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
if (visible) {
|
||||
horn.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MobSkull implements ISkull {
|
|||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha) {
|
||||
ponyHead.get().renderHead(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
ponyHead.get().renderHelmet(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
ponyHead.get().headRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
ponyHead.get().headRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ public class PlayerPonySkull implements ISkull {
|
|||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha) {
|
||||
ponyHead.renderHead(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
ponyHead.renderHelmet(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
ponyHead.headRenderList.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
ponyHead.helmetRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
deadMau5.get().render(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.minelittlepony.client.util.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface RenderList {
|
||||
void accept(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha);
|
||||
|
||||
default RenderList add(RenderList part) {
|
||||
return this;
|
||||
}
|
||||
|
||||
default RenderList add(Consumer<MatrixStack> action) {
|
||||
return add((stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> action.accept(stack));
|
||||
}
|
||||
|
||||
default RenderList add(ModelPart...parts) {
|
||||
return add(of(parts));
|
||||
}
|
||||
|
||||
default RenderList checked(BooleanSupplier check) {
|
||||
RenderList self = this;
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
if (check.getAsBoolean()) {
|
||||
self.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default void clear() {}
|
||||
|
||||
static RenderList of() {
|
||||
return new Impl(List.of());
|
||||
}
|
||||
|
||||
static RenderList of(ModelPart...parts) {
|
||||
return new Impl(Arrays.stream(parts).map(part -> (RenderList)part::render).toList());
|
||||
}
|
||||
|
||||
public class Impl implements RenderList {
|
||||
private final List<RenderList> parts;
|
||||
|
||||
Impl(List<RenderList> parts) {
|
||||
this.parts = new ArrayList<>(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderList add(RenderList part) {
|
||||
parts.add(part);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parts.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
parts.forEach(part -> part.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue