Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by RInventor7

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.

  • Author

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 by RInventor7

  • RInventor7 changed the title to Custom block entity renderer not working [1.19.2] [SOLVED]

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.