mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
bring back model rendering
This commit is contained in:
parent
1469e4ca5f
commit
5c04244e00
4 changed files with 82 additions and 48 deletions
|
@ -1,23 +1,31 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
|
||||||
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
||||||
|
import net.minecraft.client.model.Model;
|
||||||
|
import net.minecraft.client.model.geom.ModelLayers;
|
||||||
|
import net.minecraft.client.model.geom.ModelPart;
|
||||||
|
import net.minecraft.client.model.geom.PartPose;
|
||||||
|
import net.minecraft.client.model.geom.builders.*;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
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.BlockEntityRendererProvider;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png");
|
||||||
// private final AuraModel model = new AuraModel();
|
private final AuraModel model = new AuraModel();
|
||||||
|
|
||||||
public RenderAuraTimer(BlockEntityRendererProvider.Context context) {
|
public RenderAuraTimer(BlockEntityRendererProvider.Context context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,26 +43,26 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
|
||||||
var r = (type.getColor() >> 16 & 255) / 255F;
|
var r = (type.getColor() >> 16 & 255) / 255F;
|
||||||
var g = (type.getColor() >> 8 & 255) / 255F;
|
var g = (type.getColor() >> 8 & 255) / 255F;
|
||||||
var b = (type.getColor() & 255) / 255F;
|
var b = (type.getColor() & 255) / 255F;
|
||||||
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F);
|
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F);
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO model rendering
|
private static class AuraModel extends Model {
|
||||||
/* private static class AuraModel extends Model {
|
|
||||||
|
|
||||||
private final ModelRenderer box;
|
private final ModelPart model;
|
||||||
|
|
||||||
public AuraModel() {
|
public AuraModel() {
|
||||||
super(RenderType::getEntityTranslucent);
|
super(RenderType::entityTranslucent);
|
||||||
this.box = new ModelRenderer(this, 0, 0);
|
var mesh = new MeshDefinition();
|
||||||
this.box.setTextureSize(64, 64);
|
var part = mesh.getRoot();
|
||||||
this.box.addBox(0, 0, 0, 16, 16, 16);
|
part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 16, 16), PartPose.ZERO);
|
||||||
|
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
||||||
|
import net.minecraft.client.model.Model;
|
||||||
|
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;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
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.BlockEntityRendererProvider;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -17,7 +25,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
|
public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
|
||||||
//private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
||||||
|
|
||||||
public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) {
|
public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) {
|
||||||
|
|
||||||
|
@ -39,25 +47,25 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
|
||||||
stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F);
|
stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F);
|
||||||
stack.mulPose(Vector3f.XP.rotationDegrees(180F));
|
stack.mulPose(Vector3f.XP.rotationDegrees(180F));
|
||||||
stack.scale(1.002F, 1.002F, 1.002F);
|
stack.scale(1.002F, 1.002F, 1.002F);
|
||||||
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha);
|
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha);
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO model rendering
|
private static class ModelLimitRemoverGlint extends Model {
|
||||||
/* private static class ModelLimitRemoverGlint extends Model {
|
|
||||||
|
|
||||||
private final ModelRenderer box;
|
private final ModelPart model;
|
||||||
|
|
||||||
public ModelLimitRemoverGlint() {
|
public ModelLimitRemoverGlint() {
|
||||||
super(RenderType::getEntityTranslucent);
|
super(RenderType::entityTranslucent);
|
||||||
this.box = new ModelRenderer(this, 0, 0);
|
var mesh = new MeshDefinition();
|
||||||
this.box.setTextureSize(64, 64);
|
var part = mesh.getRoot();
|
||||||
this.box.addBox(0, 0, 0, 16, 16, 16);
|
part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 16, 16), PartPose.ZERO);
|
||||||
|
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStack, IVertexBuilder iVertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.box.render(matrixStack, iVertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
|
||||||
|
import net.minecraft.client.model.Model;
|
||||||
|
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;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
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.BlockEntityRendererProvider;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
@ -16,7 +24,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> {
|
public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
||||||
//private final ModelOverlay model = new ModelOverlay();
|
private final ModelOverlay model = new ModelOverlay();
|
||||||
|
|
||||||
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
|
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
|
||||||
|
|
||||||
|
@ -38,25 +46,25 @@ public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntit
|
||||||
stack.translate(-0.002F, 0, 0);
|
stack.translate(-0.002F, 0, 0);
|
||||||
}
|
}
|
||||||
var brightness = 15 << 20 | 15 << 4;
|
var brightness = 15 << 20 | 15 << 4;
|
||||||
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
|
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO model rendering
|
private static class ModelOverlay extends Model {
|
||||||
/* private static class ModelOverlay extends Model {
|
|
||||||
|
|
||||||
private final ModelPart box;
|
private final ModelPart model;
|
||||||
|
|
||||||
public ModelOverlay() {
|
public ModelOverlay() {
|
||||||
super(RenderType::entityTranslucent);
|
super(RenderType::entityTranslucent);
|
||||||
this.box = new ModelPart(this, 0, 0);
|
var mesh = new MeshDefinition();
|
||||||
this.box.setTextureSize(64, 64);
|
var part = mesh.getRoot();
|
||||||
this.box.(0, 0, 0, 16, 16, 16);
|
part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 16, 16), PartPose.ZERO);
|
||||||
|
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
package de.ellpeck.naturesaura.entities.render;
|
package de.ellpeck.naturesaura.entities.render;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
||||||
|
import net.minecraft.client.model.Model;
|
||||||
import net.minecraft.client.model.geom.ModelLayers;
|
import net.minecraft.client.model.geom.ModelLayers;
|
||||||
|
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;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
@ -18,7 +27,8 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
||||||
public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) {
|
public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) {
|
||||||
super(p_174300_, ModelLayers.MINECART);
|
super(p_174300_, ModelLayers.MINECART);
|
||||||
}
|
}
|
||||||
//private final ModelMoverMinecart model = new ModelMoverMinecart();
|
|
||||||
|
private final ModelMoverMinecart model = new ModelMoverMinecart();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderMinecartContents(EntityMoverMinecart entityIn, float partialTicks, BlockState stateIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) {
|
protected void renderMinecartContents(EntityMoverMinecart entityIn, float partialTicks, BlockState stateIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) {
|
||||||
|
@ -26,25 +36,25 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
||||||
matrixStackIn.translate(0, 22 / 16F, 0);
|
matrixStackIn.translate(0, 22 / 16F, 0);
|
||||||
matrixStackIn.translate(0, 0, 1);
|
matrixStackIn.translate(0, 0, 1);
|
||||||
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180));
|
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180));
|
||||||
//this.model.render(matrixStackIn, bufferIn.getBuffer(this.model.getRenderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
|
this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
|
||||||
matrixStackIn.popPose();
|
matrixStackIn.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO model rendering
|
private static class ModelMoverMinecart extends Model {
|
||||||
/* private static class ModelMoverMinecart extends Model {
|
|
||||||
|
|
||||||
private final ModelRenderer box;
|
private final ModelPart model;
|
||||||
|
|
||||||
public ModelMoverMinecart() {
|
public ModelMoverMinecart() {
|
||||||
super(RenderType::getEntityCutout);
|
super(RenderType::entityCutout);
|
||||||
this.box = new ModelRenderer(this, 0, 0);
|
var mesh = new MeshDefinition();
|
||||||
this.box.setTextureSize(64, 64);
|
var part = mesh.getRoot();
|
||||||
this.box.addBox(0, 0, 0, 16, 24, 16);
|
part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 24, 16), PartPose.ZERO);
|
||||||
|
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue