Jump to content

Recommended Posts

Posted (edited)

Hello! I just wanted to ask if somebody could point me in the right direction in terms of making entity renderers. I'm just stuck in understanding stuff like the MatrixStack in the following code:

 

 

 
 
 
 
  Reveal hidden contents

 

I've also seen it be used with methods like push() and pop() in here https://github.com/mekanism/Mekanism/blob/1.15x/src/main/java/mekanism/client/render/entity/RenderFlame.java (not my code).

I'm honestly just lost on whats happening or if I even need to understand it to make a renderer for my entity.

 

Help would be greatly appreciated!

Edited by chubel10
Posted

Just to add on to what I said:

 

I'm mostly confused because I thought the model controlled everything having to do with hitboxes, sizes and stuff but I already completely changed my model and the hitbox and length of the entity is unchanged —as well as the code of the renderer which I copy pasted from another vanilla class but I can't really read or understand due to all of the weird "func_227860_a_"s and the like which don't really help.

 

Thanks in advance!

Posted
  On 4/23/2020 at 3:14 AM, chubel10 said:

I'm mostly confused because I thought the model controlled everything having to do with hitboxes, sizes and stuff but I already completely changed my model and the hitbox and length of the entity is unchanged —as well as the code of the renderer which I copy pasted from another vanilla class but I can't really read or understand due to all of the weird "func_227860_a_"s and the like which don't really help.

Expand  

Model controls the entity's appearance; it doesn't control the collision box (which is used in code that handles physics). An entity can have a huge model and a small collision box at the same time.

 

MatrixStack is used to record the transformation of rendering via a stack. It is similar to the stack manipulation of GlStateManager in earlier versions.

An example of updating from GlStateManager to MatrixStack is this.

 

As for the obfuscated names, you should update your Forge to latest. The mapping has been updated in the later versions (I was using 31.1.0 and experienced the same thing).

  • Like 1

Some tips:

  Reveal hidden contents

 

Posted

Stacks in rendering is something like:

Each matrix in stack holds a series of transformations (position, rotation, scale). When you render something, it undergoes the transformation of all recorded transformation in the stack. When you pop a matrix (let's call it matrix A), it removes all the transformations after the pushing of matrix A.

 

For example (pseudocode):

pushMatrix();
translate(3, 0, 2); // move 3 units on x axis, and 2 units on z axis
renderModelA();

pushMatrix();
rotate(180, 1, 0, 0); // rotate 180 around the x axis
renderModelB();
popMatrix();

scale(2, 2, 2); // scale 2 on all axis
renderModelC();
popMatrix();

Model A would be rendered with translation of 3, 0, 2.

Model B would be rendered rotated 180 around x axis and translated 3, 0, 2.

Model C would be rendered 2x the size and translated 3, 0, 2. Since the matrix involving the rotation is already popped at the time Model C is rendered, the rotation does not apply to Model C.

  • Like 1

Some tips:

  Reveal hidden contents

 

Posted

Hello! Sorry for taking so long to reply.

 

  On 4/23/2020 at 3:32 AM, DavidM said:

An example of updating from GlStateManager to MatrixStack is this.

Expand  

Thank you for providing some code! But how did you deal with the obfuscated names? Like did you climb definitions until you reached a method without obfuscated names in order to understand it?

 

  On 4/23/2020 at 3:32 AM, DavidM said:

As for the obfuscated names, you should update your Forge to latest. The mapping has been updated in the later versions (I was using 31.1.0 and experienced the same thing).

Expand  

Thanks for the tip.

How could I go about updating my forge? do I have to do the whole setup thing again and copy my code or is there some fancy terminal code that I should learn?

 

  On 4/23/2020 at 3:41 AM, DavidM said:

Stacks

Expand  

All of your stack explanations were really helpful and they are much obliged. I'll look into your code and try to implement it !

 

Thanks in advance!

Posted (edited)
  On 4/24/2020 at 4:37 PM, chubel10 said:

Thank you for providing some code! But how did you deal with the obfuscated names? Like did you climb definitions until you reached a method without obfuscated names in order to understand it?

Expand  

I used an assortment of guessing, looking at vanilla usage, and looking at the code in the obfuscated method (I didn't realize the MCP names were in place in the latest version at that time).

 

  On 4/24/2020 at 4:37 PM, chubel10 said:

How could I go about updating my forge? do I have to do the whole setup thing again and copy my code or is there some fancy terminal code that I should learn?

Expand  

AFAIK the only thing that changes across minor versions is the build.gradle file. To update, simply download the newest mdk, replace your  build.gradle with the new one, and edit it to fit your need (add mod id, dependencies, etc). Make sure to re-import the workspace after that.

Edited by DavidM
  • Like 1

Some tips:

  Reveal hidden contents

 

  • chubel10 changed the title to [Solved][1.15.2] Help with entity renderers
Posted (edited)

searched a while but here

 

for the hitbox/collision box:

needs to be in your entity.java

@Override

public float getRenderScale() {

return this.isChild() ? 0.75F : 1.8F; }

 

Edited by talhanation

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



×
×
  • Create New...

Important Information

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