RInventor7 Posted January 30, 2023 Posted January 30, 2023 (edited) Hi! I managed to make a custom block entity render for my block entity. The renderer is correctly registered and it runs on every tick as it should be. The problem is that it’s not doing anything I have set it to do. What am I doing wrong? I just wish to move the block model, scale it smaller and rotate it 45 degrees. Thanks in advance. package com.rinventor.transportmod.entities.render.block; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import com.rinventor.transportmod.core.base.PTMBlock; import com.rinventor.transportmod.core.init.ModBlocks; import com.rinventor.transportmod.objects.blockentities.MyBlockEntity; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class MyBlockRender implements BlockEntityRenderer<MyBlockEntity> { public MyBlockRender(BlockEntityRendererProvider.Context renderManager) { super(); } @Override public void render(MyBlockEntity be, float partialTicks, PoseStack poseStack, MultiBufferSource bufferSource, int combinedLight, int combinedOverlay) { BlockState blockstate = be.getBlockState(); poseStack.pushPose(); if (blockstate.getBlock() == ModBlocks.MY_BLOCK.get()) { float f1 = 45.0F; poseStack.mulPose(Vector3f.YP.rotationDegrees(f1)); poseStack.translate(0.5D, 0.5D, 0.5D); poseStack.scale(-0.6666667F, -0.6666667F, -0.6666667F); } poseStack.popPose(); } } Edited February 2, 2023 by RInventor7 Quote
ChampionAsh5357 Posted January 31, 2023 Posted January 31, 2023 Well, you're not rendering anything. If you don't render anything in the render method, then nothing you do will show up visually. Also, you shouldn't need to check what block it is. Quote
RInventor7 Posted February 2, 2023 Author Posted February 2, 2023 (edited) Thanks for the replay. You just saved me from a lot of extra work. Thank you so much! The following code works (at least I can now see the something rendered in game): package com.rinventor.mymod.entities.render.block; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import com.rinventor.mymod.objects.blockentities.MyBlockBlockEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class MyBlockRender implements BlockEntityRenderer<MyBlockBlockEntity> { public MyBlockRender(BlockEntityRendererProvider.Context renderManager) { super(); } @Override public void render(MyBlockBlockEntity be, float partialTicks, PoseStack poseStack, MultiBufferSource bufferSource, int combinedLight, int combinedOverlay) { BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer(); BlockState blockstate = be.getBlockState(); poseStack.pushPose(); float f1 = 45.0F; poseStack.mulPose(new Vector3f().rotationDegrees(f1)); blockRenderer.renderSingleBlock(blockstate, poseStack, bufferSource, combinedLight, OverlayTexture.NO_OVERLAY, be.getModelData(), RenderType.cutout()); poseStack.popPose(); } } Edited February 2, 2023 by RInventor7 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.