Fixed *Chest* rendering

This commit is contained in:
Frank Bauer 2021-07-07 13:31:02 +02:00
parent abcf90e0bc
commit 558b1db714
2 changed files with 100 additions and 44 deletions

View file

@ -11,8 +11,8 @@ import net.fabricmc.api.Environment;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
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.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
import net.minecraft.core.Direction;
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.properties.ChestType;
import ru.bclib.blockentities.BaseChestBlockEntity;
import ru.bclib.client.models.BaseChestBlockModel;
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_RIGHT = 2;
private final ModelPart partA;
private final ModelPart partC;
private final ModelPart partB;
private final ModelPart partRightA;
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;
private final BaseChestBlockModel chestModel;
public BaseChestBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
super();
chestModel = new BaseChestBlockModel(BaseChestBlockModel.getTexturedModelData().bakeRoot());
}
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 (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 {
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 {
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();