Fixed *Chest* rendering
This commit is contained in:
parent
abcf90e0bc
commit
558b1db714
2 changed files with 100 additions and 44 deletions
|
@ -0,0 +1,91 @@
|
||||||
|
package ru.bclib.client.models;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.geom.ModelPart;
|
||||||
|
import net.minecraft.client.model.geom.PartPose;
|
||||||
|
import net.minecraft.client.model.geom.builders.*;
|
||||||
|
|
||||||
|
public class BaseChestBlockModel {
|
||||||
|
public final ModelPart partA;
|
||||||
|
public final ModelPart partC;
|
||||||
|
public final ModelPart partB;
|
||||||
|
public final ModelPart partRightA;
|
||||||
|
public final ModelPart partRightC;
|
||||||
|
public final ModelPart partRightB;
|
||||||
|
public final ModelPart partLeftA;
|
||||||
|
public final ModelPart partLeftC;
|
||||||
|
public final ModelPart partLeftB;
|
||||||
|
|
||||||
|
public static LayerDefinition getTexturedModelData() {
|
||||||
|
MeshDefinition modelData = new MeshDefinition();
|
||||||
|
PartDefinition modelPartData = modelData.getRoot();
|
||||||
|
CubeDeformation deformation_partC = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partC", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 19)
|
||||||
|
.addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC),
|
||||||
|
PartPose.ZERO);
|
||||||
|
|
||||||
|
CubeDeformation deformation_partA = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partA", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 0)
|
||||||
|
.addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA),
|
||||||
|
PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||||
|
|
||||||
|
CubeDeformation deformation_partB = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partB", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 0)
|
||||||
|
.addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB),
|
||||||
|
PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||||
|
|
||||||
|
CubeDeformation deformation_partRightC = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partRightC", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 19)
|
||||||
|
.addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC),
|
||||||
|
PartPose.ZERO);
|
||||||
|
|
||||||
|
CubeDeformation deformation_partRightA = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partRightA", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 0)
|
||||||
|
.addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA),
|
||||||
|
PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||||
|
|
||||||
|
CubeDeformation deformation_partRightB = new CubeDeformation(0.0f);
|
||||||
|
PartDefinition partRightB = modelPartData.addOrReplaceChild("partRightB", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 0)
|
||||||
|
.addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB),
|
||||||
|
PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||||
|
|
||||||
|
CubeDeformation deformation_partLeftC = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partLeftC", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 19)
|
||||||
|
.addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC),
|
||||||
|
PartPose.ZERO);
|
||||||
|
|
||||||
|
CubeDeformation deformation_partLeftA = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partLeftA", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 0)
|
||||||
|
.addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA),
|
||||||
|
PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||||
|
|
||||||
|
CubeDeformation deformation_partLeftB = new CubeDeformation(0.0f);
|
||||||
|
modelPartData.addOrReplaceChild("partLeftB", CubeListBuilder.create()
|
||||||
|
.texOffs(0, 0)
|
||||||
|
.addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB),
|
||||||
|
PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||||
|
|
||||||
|
return LayerDefinition.create(modelData, 64, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseChestBlockModel(ModelPart modelPart) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
partC = modelPart.getChild("partC");
|
||||||
|
partA = modelPart.getChild("partA");
|
||||||
|
partB = modelPart.getChild("partB");
|
||||||
|
partRightC = modelPart.getChild("partRightC");
|
||||||
|
partRightA = modelPart.getChild("partRightA");
|
||||||
|
partRightB = modelPart.getChild("partRightB");
|
||||||
|
partLeftC = modelPart.getChild("partLeftC");
|
||||||
|
partLeftA = modelPart.getChild("partLeftA");
|
||||||
|
partLeftB = modelPart.getChild("partLeftB");
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,8 +11,8 @@ import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.model.geom.ModelPart;
|
import net.minecraft.client.model.geom.ModelPart;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
|
import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -24,6 +24,7 @@ import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.ChestType;
|
import net.minecraft.world.level.block.state.properties.ChestType;
|
||||||
import ru.bclib.blockentities.BaseChestBlockEntity;
|
import ru.bclib.blockentities.BaseChestBlockEntity;
|
||||||
|
import ru.bclib.client.models.BaseChestBlockModel;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -36,46 +37,10 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
||||||
private static final int ID_LEFT = 1;
|
private static final int ID_LEFT = 1;
|
||||||
private static final int ID_RIGHT = 2;
|
private static final int ID_RIGHT = 2;
|
||||||
|
|
||||||
private final ModelPart partA;
|
private final BaseChestBlockModel chestModel;
|
||||||
private final ModelPart partC;
|
public BaseChestBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
|
||||||
private final ModelPart partB;
|
super();
|
||||||
private final ModelPart partRightA;
|
chestModel = new BaseChestBlockModel(BaseChestBlockModel.getTexturedModelData().bakeRoot());
|
||||||
private final ModelPart partRightC;
|
|
||||||
private final ModelPart partRightB;
|
|
||||||
private final ModelPart partLeftA;
|
|
||||||
private final ModelPart partLeftC;
|
|
||||||
private final ModelPart partLeftB;
|
|
||||||
|
|
||||||
public BaseChestBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
|
|
||||||
super(blockEntityRenderDispatcher);
|
|
||||||
|
|
||||||
this.partC = new ModelPart(64, 64, 0, 19);
|
|
||||||
this.partC.addBox(1.0F, 0.0F, 1.0F, 14.0F, 9.0F, 14.0F, 0.0F);
|
|
||||||
this.partA = new ModelPart(64, 64, 0, 0);
|
|
||||||
this.partA.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
|
|
||||||
this.partA.y = 9.0F;
|
|
||||||
this.partA.z = 1.0F;
|
|
||||||
this.partB = new ModelPart(64, 64, 0, 0);
|
|
||||||
this.partB.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
|
|
||||||
this.partB.y = 8.0F;
|
|
||||||
this.partRightC = new ModelPart(64, 64, 0, 19);
|
|
||||||
this.partRightC.addBox(1.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
|
|
||||||
this.partRightA = new ModelPart(64, 64, 0, 0);
|
|
||||||
this.partRightA.addBox(1.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
|
|
||||||
this.partRightA.y = 9.0F;
|
|
||||||
this.partRightA.z = 1.0F;
|
|
||||||
this.partRightB = new ModelPart(64, 64, 0, 0);
|
|
||||||
this.partRightB.addBox(15.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
|
|
||||||
this.partRightB.y = 8.0F;
|
|
||||||
this.partLeftC = new ModelPart(64, 64, 0, 19);
|
|
||||||
this.partLeftC.addBox(0.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
|
|
||||||
this.partLeftA = new ModelPart(64, 64, 0, 0);
|
|
||||||
this.partLeftA.addBox(0.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
|
|
||||||
this.partLeftA.y = 9.0F;
|
|
||||||
this.partLeftA.z = 1.0F;
|
|
||||||
this.partLeftB = new ModelPart(64, 64, 0, 0);
|
|
||||||
this.partLeftB.addBox(0.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
|
|
||||||
this.partLeftB.y = 8.0F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(BaseChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) {
|
public void render(BaseChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||||
|
@ -111,12 +76,12 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
||||||
|
|
||||||
if (isDouble) {
|
if (isDouble) {
|
||||||
if (chestType == ChestType.LEFT) {
|
if (chestType == ChestType.LEFT) {
|
||||||
renderParts(matrices, vertexConsumer, this.partLeftA, this.partLeftB, this.partLeftC, pitch, blockLight, overlay);
|
renderParts(matrices, vertexConsumer, chestModel.partLeftA, chestModel.partLeftB, chestModel.partLeftC, pitch, blockLight, overlay);
|
||||||
} else {
|
} else {
|
||||||
renderParts(matrices, vertexConsumer, this.partRightA, this.partRightB, this.partRightC, pitch, blockLight, overlay);
|
renderParts(matrices, vertexConsumer, chestModel.partRightA, chestModel.partRightB, chestModel.partRightC, pitch, blockLight, overlay);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
renderParts(matrices, vertexConsumer, this.partA, this.partB, this.partC, pitch, blockLight, overlay);
|
renderParts(matrices, vertexConsumer, chestModel.partA, chestModel.partB, chestModel.partC, pitch, blockLight, overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
matrices.popPose();
|
matrices.popPose();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue