Jump to content

Rendering block entity at an angle of 45 degrees [1.19.2] [SOLVED]


Recommended Posts

Posted (edited)

Hi! I have a working block entity renderer, but there’s 2 problems with it, that I can’t figure out how to solve. All I wish to do is to rotate the block by 45 degrees. Of course angles can be 0, 45, 90, 135, 180 etc.

@OnlyIn(Dist.CLIENT)
public class MyBlockRender implements BlockEntityRenderer<MyBlockBlockEntity> {
	BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();

	public MyBlockRender(BlockEntityRendererProvider.Context renderManager) {
		super();
		blockRenderer = renderManager.getBlockRenderDispatcher();
	}

	@Override
	public void render(MyBlockBlockEntity be, float partialTicks, PoseStack poseStack, MultiBufferSource bufferSource, int combinedLight, int combinedOverlay) {
		BlockState bs = be.getBlockState();
		
		poseStack.pushPose();
		poseStack.translate(0.0, 1.5, 0.0);
		float f = PTMBlock.getRotationInDeg(bs);
		poseStack.mulPose(Vector3f.YP.rotationDegrees(f));

		blockRenderer.renderSingleBlock(bs, poseStack, bufferSource, combinedLight, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, RenderType.cutout());
		poseStack.popPose();
	}

}

1) As my code indicates I move the model up. This immediately will indicate that it renders 2 blocks in 1. How can I stop the original renderer because otherwise (if no translation) it will render 2 models in one and if I rotate the model 45 degrees only my rendered model is at the correct angle.

2) Using 

poseStack.mulPose(Vector3f.YP.rotationDegrees(45f))

is messing up the model location. I want the model to be inside the bounding box but it’s rotated half a block on the side (depending on the angle). Does it got to do something with the actual block model.json or do i just have to use the translate function to center the model?

Edited by RInventor7
Fully solved
Posted
  On 2/2/2023 at 9:13 PM, RInventor7 said:

How can I stop the original renderer because otherwise (if no translation) it will render 2 models in one and if I rotate the model 45 degrees only my rendered model is at the correct angle.

Expand  

You can set the RenderShape to ENTITYBLOCK_ANIMATED via #getRenderShape. If you want the original model to render occasionally, you can change it via the block state.

  On 2/2/2023 at 9:13 PM, RInventor7 said:

I want the model to be inside the bounding box but it’s rotated half a block on the side (depending on the angle).

Expand  

You need to translate it to the center and then translate it back. If you want to understand what's going, I suggest rotating the model every 4 or 5 ticks so you can see where the center point is located. Rotation not around the origin point constitutes translating the model to the origin, rotating, then translating back to the original position.

  • RInventor7 changed the title to Rendering block entity at an angle of 45 degrees [1.19.2] [SOLVED]
Posted (edited)

The rotating works perfectly. Thank you.

However, setting the RenderType to ENTITYBLOCK_ANIMATED makes the default model invisible which is good, but it makes my rendered model also invisible. If I do not set the RenderType it renders still 2 models in 1. I can render one model (for example a block of glass) and rotate it, but if I render my block I either get 2 models in 1 or nothing. Is it possible to somehow only render 1 model (the one that I render myself) of my block? Maybe it is possible to somehow re-render the original model with rotation instead of rendering a new model with correct rotation?

My block has 5 different states which are defined by the blockstate.json and an IntegerProperty. I’m just trying to rotate the block without using the FACING property because then i’d have to make two json models of all the 5 states (one straight and the other at 45 deg angle) and then rotate them. So the whole idea is to use custom renderer to reduce model files from 20 to 5.

Edited by RInventor7
  • RInventor7 changed the title to Rendering block entity at an angle of 45 degrees [1.19.2]
Posted
  On 2/3/2023 at 8:00 PM, RInventor7 said:

So the whole idea is to use custom renderer to reduce model files from 20 to 5.

Expand  

So, as a quick tip, it's always better to use model files compared to BERs when possible. the JSON models (along with custom model loaders) can be cached by the chunk which is typically much more efficient to render than having to calculate the same data every tick. 20 models is negligible compared to 1 BER in most cases.

  On 2/3/2023 at 8:00 PM, RInventor7 said:

However, setting the RenderType to ENTITYBLOCK_ANIMATED makes the default model invisible which is good, but it makes my rendered model also invisible.

Expand  

I mean, that's typically the case since the model isn't loaded by default. You would need to force the model to load yourself via the ModelEvent$RegisterAdditional event on the mod bus.

  • RInventor7 changed the title to Rendering block entity at an angle of 45 degrees [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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I checked the hash like you said and it came back as OK each time, also may I ask what you mean by debug mode during installation?  
    • My name is Clara Bennett, and I almost let cryptocurrency destroy me.  Two years ago, after selling my green e-commerce startup, I plunged headfirst into the crypto world. yield farming , I was all in. I believed I wasn’t just investing; I was participating in the next great technological revolution. Within months, my portfolio skyrocketed to $200,000. I even started sketching ideas for a blockchain-based microloan platform to empower small entrepreneurs around the world. Crypto felt like pure freedom and limitless potential. I thought I was untouchable. I thought wrong. It happened through a single email. It looked like a standard security update from my wallet provider polished, routine, and harmless. I interacted with it briefly, thinking it was legitimate. Hours later, I checked my account and realized my entire wallet had been drained. Every token, every coin, gone. I sat there in disbelief, replaying the moment over and over. I had built my career on being cautious with technology, yet somehow, I had still been compromised. The blockchain’s promise of "irreversible transactions" now felt like a cruel joke  .Devastated and desperate, I scoured forums for solutions. Most people told me there was no hope once crypto is gone, it’s gone. Still, I refused to give up. That’s when I stumbled across FUNDS RETRIEVER ENGINEER . I decided to reach out. From the beginning, they were empathetic, and honest about the challenges. They explained their process step-by-step, focusing on tracing transactions, tracking down phishing operators, and leveraging advanced blockchain analytics. It wasn't an overnight fix. It took weeks of meticulous investigation, technical recovery work, and legal coordination .But in the end, their persistence paid off. FUNDS RETRIEVER ENGINEER  was able to trace the stolen funds across multiple wallets and exchanges. Through a combination of technical expertise and strategic action, they managed to recover the full amount I had lost. Today, my crypto portfolio is intact once again. More importantly, I’ve regained my confidence though I am now much wiser and far more cautious. I learned the hard way that while crypto offers incredible opportunities, it also demands extreme vigilance. Thanks to FUNDS RETRIEVER ENGINEER , I recovered my lost funds and  also reclaimed my future in the digital economy. For help  W H A T S A P P:  +1  8  0 2 9 5 2 3 4 7 0 E   m  a I L       F U N D S R  E T R  I E V E R  [@]  E  N  G  I  N  E  E  R.  C  O  M
    • 1. Did you try to remove your system cache or something? 2. Also check jar hash before installing (if it's ok): sha1sum jar_name.jar > jar_name.jar.sha1 sha1sum -c jar_name.jar.sha1 Do this a few times with some interval. This can find out if your hash can be different somehow (garbage files inside).  Also try using sha224sum / sha256sum / sha384sum / sha512sum / shasum. And do you have any debug mode during installation?   UPDATED: and it can be just fixing by chmod'ing jar file. Check its -lZ 
    • I get these errors when trying to install any version (this ones for 47.3.33 for instance):  Processor failed, invalid outputs:     /home/user/.local/share/FreesmLauncher/instances/1.20.1/minecraft/libraries/net/minecraft/server/1.20.1-20230612.114412/server-1.20.1-20230612.114412-slim.jar       Expected: 9e06bdd77ca6d95b2cced0bf372245f753eeb16a       Actual:   f1e5a0cc3c9f7c58f26524a43c5badc06ca0bac4     /home/user/.local/share/FreesmLauncher/instances/1.20.1/minecraft/libraries/net/minecraft/server/1.20.1-20230612.114412/server-1.20.1-20230612.114412-extra.jar       Expected: 13522e3278befd103064d91a199451df4cd2633f       Actual:   eb1dafb7bee2ace5d55d90b65e73c2196b1991f3 I've tried sklauncher and freesm launcher and they throw the same error, tried installing it with the official forge installer too but same error. Also tried different versions of java: 17, 21, 24. Forge for previous versions install fine, I'm on Linux CachyOS.  
  • Topics

×
×
  • Create New...

Important Information

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