[Tutorial] Render Scaling Up-Down for you entities with MatrixStack (make your mob bigger/smaller)

Started by minheragon12345 on

Topic category: User side tutorials

Last seen on 09:48, 26. Sep 2022
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] Render Scaling Up-Down for you entities with MatrixStack (make your mob bigger/smaller)
Wed, 04/28/2021 - 11:43 (edited)

Hey you! Yes, you! Have you ever made a model for your entity, added them to your mod, and then found out that the mob is smaller or bigger than you wanted? If true, this is WHAT you're looking for!
Sample

First of all, this is where I first reached to MatrixStack, and from that, I explore more then make this tutorial.

https://mcreator.net/forum/62190/scale-mob-code?page=0

Now let's get into it!

Step 1: You need to lock your element (of course), then choose to edit the code:
render
- If you're in 1.15, choose YourEntityEntity.java (in my case is NormalEntity.java)

- If you're in 1.16, choose YourEntityRender.java (mine is NormalRender.java)

Step 2: You'll need to scroll down and find the Render part (both 1.15 and 1.16), like this (my model is direwolf so it says Direwolf)
direwolf

Step 3: You need to replace entire thing (from "@Override" to "packedOverlay);" ) with this:
        @Override
        public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
                float alpha) {
            matrixStack.push();
            matrixStack.translate(0f, 1.5f - t * 1.5f, 0f);
            matrixStack.scale(xf, yf, zf);
            Direwolf.render(matrixStack, buffer, packedLight, packedOverlay);
            matrixStack.pop();

Then you'll have this:
xyzt

Step 4: Now all you need is to change the x y z t variable: (by default, originally from your model, every variable is 1)
You can see some examples from the first image from step 1, the middle one is the default, everything is 1. Any variable that is smaller than 1 makes the entity small, greater than 1 makes it bigger.
- z = front to back [The perfect example is number 1]
- x = sideway [number 2]
- y = height [number 3]

Note: when you're changing the y variable, you need to change the t variable too, change it so t = y. If not you're entity will be underground.

With that in mind: [number 4] is what I made by changing every variable to 1.5 (x=y=z=t=1.5), the entity has turned from chicken-side to wolf-side.

Another example is this, when you place a x=y=z=t=0.5 wolf next to a x=y=z=t=3 wolf. 
Sample

Personally, I really do want this to be added to Mcreator (so I won't need to lock and relock the code every time I want to edit the mobs), I photoshoped this: 
Photoshop

Edited by minheragon12345 on Wed, 04/28/2021 - 11:43
Last seen on 02:51, 19. Feb 2022
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you post a screenshot…
Tue, 01/11/2022 - 23:53

Could you post a screenshot of your code please @PFFgamer?

Last seen on 19:16, 19. Apr 2024
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is the error
Sat, 02/19/2022 - 22:45

errorThis is the error

Last seen on 01:15, 25. Jul 2022
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Trying to brainstorm here,…
Thu, 03/10/2022 - 23:47

Trying to brainstorm here, if it would be possible to use this method to make a baby/adult transition in the same entity? Like instead of having a baby turtle and an adult turtle and having it despawn the baby and spawn an adult upon growing up, add the custom code to the adult model and have it start out at half size (so I guess .5 in all categories), then a little custom code snippet in the growth procedure that changes those numbers to 1 when it grows up? To return the model size to adult size. I'm not sure if that's feasible or not. I can't use the two-entity method cause I can't figure out how to keep it tamed to the same player when it grows up and switches entities.

Last seen on 20:08, 6. Sep 2022
Joined Apr 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can I do this in 1.18.2?
Wed, 08/03/2022 - 17:49

Can I do this in 1.18.2?