mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Ponify the bogged
This commit is contained in:
parent
e922b397c8
commit
a3f71175cc
9 changed files with 155 additions and 63 deletions
|
@ -1,6 +1,8 @@
|
||||||
package com.minelittlepony.client.model;
|
package com.minelittlepony.client.model;
|
||||||
|
|
||||||
import net.minecraft.client.model.Model;
|
import net.minecraft.client.model.Model;
|
||||||
|
import net.minecraft.client.model.Model.SinglePartModel;
|
||||||
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.model.ModelPart;
|
import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ public final class ModelType {
|
||||||
public static final ModelKey<ZomponyModel<?>> ZOMBIE = register("zombie", ZomponyModel::new);
|
public static final ModelKey<ZomponyModel<?>> ZOMBIE = register("zombie", ZomponyModel::new);
|
||||||
public static final ModelKey<PiglinPonyModel> PIGLIN = register("piglin", PiglinPonyModel::new);
|
public static final ModelKey<PiglinPonyModel> PIGLIN = register("piglin", PiglinPonyModel::new);
|
||||||
public static final ModelKey<SkeleponyModel<?>> SKELETON = register("skeleton", SkeleponyModel::new);
|
public static final ModelKey<SkeleponyModel<?>> SKELETON = register("skeleton", SkeleponyModel::new);
|
||||||
|
public static final ModelKey<SinglePartModel> BOGGED_MUSHROOMS = register("bogged_mushrooms", tree -> new SinglePartModel(tree, RenderLayer::getEntityTranslucent));
|
||||||
public static final ModelKey<SkeleponyModel<?>> SKELETON_CLOTHES = register("skeleton_clothes", SkeleponyModel::new);
|
public static final ModelKey<SkeleponyModel<?>> SKELETON_CLOTHES = register("skeleton_clothes", SkeleponyModel::new);
|
||||||
public static final ModelKey<PillagerPonyModel> PILLAGER = register("pillager", PillagerPonyModel::new);
|
public static final ModelKey<PillagerPonyModel> PILLAGER = register("pillager", PillagerPonyModel::new);
|
||||||
public static final ModelKey<IllagerPonyModel<?>> ILLAGER = register("illager", IllagerPonyModel::new);
|
public static final ModelKey<IllagerPonyModel<?>> ILLAGER = register("illager", IllagerPonyModel::new);
|
||||||
|
|
|
@ -52,6 +52,7 @@ public record MobRenderers (String name, BiConsumer<MobRenderers, EntityRenderer
|
||||||
public static final MobRenderers SKELETON = register("skeletons", (state, registry) -> {
|
public static final MobRenderers SKELETON = register("skeletons", (state, registry) -> {
|
||||||
registry.registerEntityRenderer(EntityType.SKELETON, state, SkeleponyRenderer::skeleton);
|
registry.registerEntityRenderer(EntityType.SKELETON, state, SkeleponyRenderer::skeleton);
|
||||||
registry.registerEntityRenderer(EntityType.STRAY, state, SkeleponyRenderer::stray);
|
registry.registerEntityRenderer(EntityType.STRAY, state, SkeleponyRenderer::stray);
|
||||||
|
registry.registerEntityRenderer(EntityType.BOGGED, state, SkeleponyRenderer::bogged);
|
||||||
registry.registerEntityRenderer(EntityType.WITHER_SKELETON, state, SkeleponyRenderer::wither);
|
registry.registerEntityRenderer(EntityType.WITHER_SKELETON, state, SkeleponyRenderer::wither);
|
||||||
});
|
});
|
||||||
public static final MobRenderers GUARDIAN = register("guardians", (state, registry) -> {
|
public static final MobRenderers GUARDIAN = register("guardians", (state, registry) -> {
|
||||||
|
|
|
@ -1,68 +1,102 @@
|
||||||
package com.minelittlepony.client.render.entity;
|
package com.minelittlepony.client.render.entity;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.ModelAttributes;
|
import com.minelittlepony.api.model.*;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
|
||||||
import com.minelittlepony.api.pony.Pony;
|
import com.minelittlepony.api.pony.Pony;
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.client.MineLittlePony;
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||||
import com.minelittlepony.client.render.entity.feature.AbstractClothingFeature;
|
import com.minelittlepony.client.render.entity.feature.ClothingFeature;
|
||||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.Model.SinglePartModel;
|
||||||
|
import net.minecraft.client.render.*;
|
||||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.mob.*;
|
import net.minecraft.entity.mob.*;
|
||||||
|
import net.minecraft.util.Colors;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class SkeleponyRenderer<T extends AbstractSkeletonEntity> extends PonyRenderer<T, SkeleponyRenderer.State, SkeleponyModel<SkeleponyRenderer.State>> {
|
public class SkeleponyRenderer<T extends AbstractSkeletonEntity, S extends SkeleponyRenderer.State> extends PonyRenderer<T, S, SkeleponyModel<S>> {
|
||||||
public static final Identifier SKELETON = MineLittlePony.id("textures/entity/skeleton/skeleton_pony.png");
|
public static final Identifier SKELETON = MineLittlePony.id("textures/entity/skeleton/skeleton_pony.png");
|
||||||
public static final Identifier WITHER = MineLittlePony.id("textures/entity/skeleton/skeleton_wither_pony.png");
|
public static final Identifier WITHER = MineLittlePony.id("textures/entity/skeleton/skeleton_wither_pony.png");
|
||||||
public static final Identifier STRAY = MineLittlePony.id("textures/entity/skeleton/stray_pony.png");
|
public static final Identifier STRAY = MineLittlePony.id("textures/entity/skeleton/stray_pony.png");
|
||||||
|
public static final Identifier BOGGED = MineLittlePony.id("textures/entity/skeleton/bogged_pony.png");
|
||||||
|
|
||||||
|
public static final Identifier STRAY_SKELETON_OVERLAY = MineLittlePony.id("textures/entity/skeleton/stray_pony_overlay.png");
|
||||||
|
public static final Identifier BOGGED_SKELETON_OVERLAY = MineLittlePony.id("textures/entity/skeleton/bogged_pony_overlay.png");
|
||||||
|
|
||||||
public SkeleponyRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
public SkeleponyRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||||
super(context, ModelType.SKELETON, TextureSupplier.of(texture), scale);
|
super(context, ModelType.SKELETON, TextureSupplier.of(texture), scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public SkeleponyRenderer.State createRenderState() {
|
public S createRenderState() {
|
||||||
return new State();
|
return (S)new State();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkeleponyRenderer<SkeletonEntity> skeleton(EntityRendererFactory.Context context) {
|
public static SkeleponyRenderer<SkeletonEntity, State> skeleton(EntityRendererFactory.Context context) {
|
||||||
return new SkeleponyRenderer<>(context, SKELETON, 1);
|
return new SkeleponyRenderer<>(context, SKELETON, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkeleponyRenderer<StrayEntity> stray(EntityRendererFactory.Context context) {
|
public static SkeleponyRenderer<StrayEntity, State> stray(EntityRendererFactory.Context context) {
|
||||||
return PonyRenderer.appendFeature(new SkeleponyRenderer<>(context, STRAY, 1), StrayClothingFeature::new);
|
return PonyRenderer.appendFeature(new SkeleponyRenderer<StrayEntity, State>(context, STRAY, 1), ctx -> {
|
||||||
|
return new ClothingFeature<>(ctx, ModelType.SKELETON_CLOTHES, STRAY_SKELETON_OVERLAY);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkeleponyRenderer<WitherSkeletonEntity> wither(EntityRendererFactory.Context context) {
|
public static SkeleponyRenderer<BoggedEntity, BoggedState> bogged(EntityRendererFactory.Context context) {
|
||||||
|
return PonyRenderer.appendFeature(PonyRenderer.appendFeature(new SkeleponyRenderer<>(context, BOGGED, 1) {
|
||||||
|
@Override
|
||||||
|
public BoggedState createRenderState() {
|
||||||
|
return new BoggedState();
|
||||||
|
}
|
||||||
|
}, ctx -> {
|
||||||
|
return new ClothingFeature<>(ctx, ModelType.SKELETON_CLOTHES, BOGGED_SKELETON_OVERLAY);
|
||||||
|
}), BoggedMushroomsFeature::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkeleponyRenderer<WitherSkeletonEntity, State> wither(EntityRendererFactory.Context context) {
|
||||||
return new SkeleponyRenderer<>(context, WITHER, 1.2F);
|
return new SkeleponyRenderer<>(context, WITHER, 1.2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StrayClothingFeature<
|
public static class BoggedMushroomsFeature<
|
||||||
T extends AbstractSkeletonEntity,
|
T extends AbstractSkeletonEntity,
|
||||||
S extends SkeleponyRenderer.State
|
S extends SkeleponyRenderer.State
|
||||||
> extends AbstractClothingFeature<T, S, SkeleponyModel<S>> {
|
> extends FeatureRenderer<BoggedState, SkeleponyModel<BoggedState>> {
|
||||||
public static final Identifier STRAY_SKELETON_OVERLAY = MineLittlePony.id("textures/entity/skeleton/stray_pony_overlay.png");
|
public static final Identifier MUSHROOMS = MineLittlePony.id("textures/entity/skeleton/bogged_pony_mushrooms.png");
|
||||||
|
|
||||||
private final SkeleponyModel<S> overlayModel = ModelType.SKELETON_CLOTHES.createModel();
|
private final SinglePartModel model = ModelType.BOGGED_MUSHROOMS.createModel();
|
||||||
|
|
||||||
public StrayClothingFeature(LivingEntityRenderer<T, S, SkeleponyModel<S>> render) {
|
public BoggedMushroomsFeature(LivingEntityRenderer<BoggedEntity, BoggedState, SkeleponyModel<BoggedState>> renderer) {
|
||||||
super(render);
|
super(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SkeleponyModel<S> getOverlayModel() {
|
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, BoggedState state, float limbAngle, float limbDistance) {
|
||||||
return overlayModel;
|
if (!state.sheared) {
|
||||||
|
matrices.push();
|
||||||
|
getContextModel().transform(state, BodyPart.HEAD, matrices);
|
||||||
|
getContextModel().head.rotate(matrices);
|
||||||
|
VertexConsumer buffer = vertices.getBuffer(model.getLayer(MUSHROOMS));
|
||||||
|
model.render(matrices, buffer, light, OverlayTexture.DEFAULT_UV, Colors.WHITE);
|
||||||
|
matrices.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BoggedState extends State {
|
||||||
|
public boolean sheared;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Identifier getOverlayTexture() {
|
public void updateState(LivingEntity entity, PonyModel<?> model, Pony pony, ModelAttributes.Mode mode) {
|
||||||
return STRAY_SKELETON_OVERLAY;
|
super.updateState(entity, model, pony, mode);
|
||||||
|
sheared = entity instanceof BoggedEntity bogged && bogged.isSheared();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.minelittlepony.client.render.entity.feature;
|
|
||||||
|
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.util.Colors;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
|
||||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
|
||||||
|
|
||||||
// separate class in case I need it later
|
|
||||||
public abstract class AbstractClothingFeature<
|
|
||||||
T extends LivingEntity,
|
|
||||||
S extends PonyRenderState,
|
|
||||||
M extends BipedEntityModel<? super S> & PonyModel<? super S>
|
|
||||||
> extends FeatureRenderer<S, M> {
|
|
||||||
|
|
||||||
protected final FeatureRendererContext<S, M> renderer;
|
|
||||||
|
|
||||||
public AbstractClothingFeature(FeatureRendererContext<S, M> render) {
|
|
||||||
super(render);
|
|
||||||
renderer = render;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, S state, float limbAngle, float limbDistance) {
|
|
||||||
M overlayModel = getOverlayModel();
|
|
||||||
|
|
||||||
overlayModel.setAngles(state);
|
|
||||||
VertexConsumer buffer = vertices.getBuffer(overlayModel.getLayer(getOverlayTexture()));
|
|
||||||
overlayModel.render(matrices, buffer, light, OverlayTexture.DEFAULT_UV, Colors.WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract M getOverlayModel();
|
|
||||||
|
|
||||||
protected abstract Identifier getOverlayTexture();
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.minelittlepony.client.render.entity.feature;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
|
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||||
|
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.util.Colors;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.model.ClientPonyModel;
|
||||||
|
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||||
|
import com.minelittlepony.mson.api.ModelKey;
|
||||||
|
|
||||||
|
// separate class in case I need it later
|
||||||
|
public class ClothingFeature<
|
||||||
|
S extends PonyRenderState,
|
||||||
|
M extends ClientPonyModel<S>
|
||||||
|
> extends FeatureRenderer<S, M> {
|
||||||
|
|
||||||
|
protected final FeatureRendererContext<S, M> context;
|
||||||
|
private final M model;
|
||||||
|
private final Identifier texture;
|
||||||
|
|
||||||
|
public ClothingFeature(FeatureRendererContext<S, M> context, ModelKey<? super M> model, Identifier texture) {
|
||||||
|
super(context);
|
||||||
|
this.context = context;
|
||||||
|
this.model = model.createModel();
|
||||||
|
this.texture = texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, S state, float limbAngle, float limbDistance) {
|
||||||
|
model.setAngles(state);
|
||||||
|
VertexConsumer buffer = vertices.getBuffer(model.getLayer(texture));
|
||||||
|
model.render(matrices, buffer, light, OverlayTexture.DEFAULT_UV, Colors.WHITE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
"texture": {"u": 50, "w": 64, "h": 32},
|
||||||
|
"data": {
|
||||||
|
"mushrooms": {
|
||||||
|
"pivot": [0, 1, -2],
|
||||||
|
"children": {
|
||||||
|
"red_mushroom_1": {
|
||||||
|
"texture": {"v": 16},
|
||||||
|
"pivot": [3, -8, 3],
|
||||||
|
"rotate": [0, 45, 0],
|
||||||
|
"cubes": [
|
||||||
|
{ "from": [-3, -3, 0], "size": [6, 4, 0]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"red_mushroom_2": {
|
||||||
|
"texture": {"v": 16},
|
||||||
|
"pivot": [3, -8, 3],
|
||||||
|
"rotate": [0, 134, 0],
|
||||||
|
"cubes": [
|
||||||
|
{ "from": [-3, -3, 0], "size": [6, 4, 0]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"brown_mushroom_1": {
|
||||||
|
"texture": {"v": 22},
|
||||||
|
"pivot": [-3, -8, -3],
|
||||||
|
"rotate": [0, 45, 0],
|
||||||
|
"cubes": [
|
||||||
|
{ "from": [-3, -3, 0], "size": [6, 4, 0]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"brown_mushroom_2": {
|
||||||
|
"texture": {"v": 22},
|
||||||
|
"pivot": [-3, -8, -3],
|
||||||
|
"rotate": [0, 134, 0],
|
||||||
|
"cubes": [
|
||||||
|
{ "from": [-3, -3, 0], "size": [6, 4, 0]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"brown_mushroom_3": {
|
||||||
|
"texture": {"v": 28},
|
||||||
|
"pivot": [-2, -1, 4],
|
||||||
|
"rotate": [-90, 0, 45],
|
||||||
|
"cubes": [
|
||||||
|
{ "from": [-3, -4, 0], "size": [6, 4, 0]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"brown_mushroom_4": {
|
||||||
|
"texture": {"v": 28},
|
||||||
|
"pivot": [-2, -1, 4],
|
||||||
|
"rotate": [-90, 0, 134],
|
||||||
|
"cubes": [
|
||||||
|
{ "from": [-3, -4, 0], "size": [6, 4, 0]}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
Loading…
Reference in a new issue