2019-01-22 16:10:27 +01:00
|
|
|
package de.ellpeck.naturesaura.entities.render;
|
|
|
|
|
2021-12-15 14:26:42 +01:00
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
2021-12-19 18:47:50 +01:00
|
|
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
2021-12-15 14:26:42 +01:00
|
|
|
import com.mojang.math.Vector3f;
|
2019-01-25 21:35:07 +01:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
2019-01-22 16:10:27 +01:00
|
|
|
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
2021-12-19 18:47:50 +01:00
|
|
|
import net.minecraft.client.model.Model;
|
2021-12-15 14:26:42 +01:00
|
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
2021-12-19 18:47:50 +01:00
|
|
|
import net.minecraft.client.model.geom.ModelPart;
|
|
|
|
import net.minecraft.client.model.geom.PartPose;
|
|
|
|
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
|
|
|
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
|
|
|
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
2021-12-15 14:26:42 +01:00
|
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
2021-12-19 18:47:50 +01:00
|
|
|
import net.minecraft.client.renderer.RenderType;
|
2021-12-15 14:26:42 +01:00
|
|
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
2021-12-19 18:47:50 +01:00
|
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
2021-12-15 14:26:42 +01:00
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
2019-01-22 16:10:27 +01:00
|
|
|
|
2019-10-20 22:30:49 +02:00
|
|
|
public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
2019-01-25 21:35:07 +01:00
|
|
|
|
|
|
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/mover_cart.png");
|
|
|
|
|
2021-12-15 14:26:42 +01:00
|
|
|
public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) {
|
|
|
|
super(p_174300_, ModelLayers.MINECART);
|
2019-01-22 16:10:27 +01:00
|
|
|
}
|
2021-12-19 18:47:50 +01:00
|
|
|
|
|
|
|
private final ModelMoverMinecart model = new ModelMoverMinecart();
|
2019-01-22 16:10:27 +01:00
|
|
|
|
|
|
|
@Override
|
2021-12-15 14:26:42 +01:00
|
|
|
protected void renderMinecartContents(EntityMoverMinecart entityIn, float partialTicks, BlockState stateIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) {
|
|
|
|
matrixStackIn.pushPose();
|
2020-01-29 18:18:41 +01:00
|
|
|
matrixStackIn.translate(0, 22 / 16F, 0);
|
|
|
|
matrixStackIn.translate(0, 0, 1);
|
2021-12-15 14:26:42 +01:00
|
|
|
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180));
|
2021-12-19 18:47:50 +01:00
|
|
|
this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
|
2021-12-15 14:26:42 +01:00
|
|
|
matrixStackIn.popPose();
|
2019-01-25 21:35:07 +01:00
|
|
|
}
|
|
|
|
|
2021-12-19 18:47:50 +01:00
|
|
|
private static class ModelMoverMinecart extends Model {
|
2019-01-25 21:35:07 +01:00
|
|
|
|
2021-12-19 18:47:50 +01:00
|
|
|
private final ModelPart model;
|
2019-01-25 21:35:07 +01:00
|
|
|
|
|
|
|
public ModelMoverMinecart() {
|
2021-12-19 18:47:50 +01:00
|
|
|
super(RenderType::entityCutout);
|
|
|
|
var mesh = new MeshDefinition();
|
|
|
|
var part = mesh.getRoot();
|
|
|
|
part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 24, 16), PartPose.ZERO);
|
|
|
|
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
|
2019-01-25 21:35:07 +01:00
|
|
|
}
|
2019-01-22 16:10:27 +01:00
|
|
|
|
2020-01-29 18:18:41 +01:00
|
|
|
@Override
|
2021-12-19 18:47:50 +01:00
|
|
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
|
|
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
2019-01-25 21:35:07 +01:00
|
|
|
}
|
2021-12-19 18:47:50 +01:00
|
|
|
}
|
2019-01-22 16:10:27 +01:00
|
|
|
}
|