Topic category: Help with Minecraft modding (Java Edition)
So, in 1.16.5 I used this guide to change the size of an entity in-game. The render code for models however changed in 1.17.1. Does anybody know how to change the render size of a model in 1.17.1?
In case anybody is also looking for how to rescale an entity model in the renderer in 1.17, here is the solution I found.
Instead of typing
"@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 - 0.5 * 1.5f, 0f);
matrixStack.scale(0.5f, 0.5f, 0.5f);
main.render(matrixStack, buffer, packedLight, packedOverlay);
matrixStack.pop();"
Type
"@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
float red, float green, float blue, float alpha) {
poseStack.pushPose();
poseStack.translate(0f, 1.5f - 0.5 * 1.5f, 0f);
poseStack.scale(0.5f, 0.5f, 0.5f);
main.render(poseStack, buffer, packedLight, packedOverlay);
poseStack.popPose();"
Where do we put this?
Does not work
C:\Users\VuFlub\MCreatorWorkspaces\addons\src\main\java\net\mcreator\addons\client\renderer\TestRenderer.java:21: error: cannot find symbol
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
^
symbol: class PoseStack
location: class TestRenderer
C:\Users\VuFlub\MCreatorWorkspaces\addons\src\main\java\net\mcreator\addons\client\renderer\TestRenderer.java:21: error: cannot find symbol
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
^
symbol: class VertexConsumer
location: class TestRenderer
C:\Users\VuFlub\MCreatorWorkspaces\addons\src\main\java\net\mcreator\addons\client\renderer\TestRenderer.java:20: error: method does not override or implement a method from a supertype
@Override
^
C:\Users\VuFlub\MCreatorWorkspaces\addons\src\main\java\net\mcreator\addons\client\renderer\TestRenderer.java:26: error: cannot find symbol
main.render(poseStack, buffer, packedLight, packedOverlay);
^
symbol: variable main
location: class TestRenderer
4 errors
FAILURE: Build failed with an exception.
What version of Minecraft is your mod for? Could you send a screenshot of the code you put please?
I use this exact code on 1.17.1 to rescale my model in game.
I'm using the same version. Here the link to where i put code https://ibb.co/vZH60wk
Sorry, I forgot that the file where you put the code at is different in 1.17.1 than it is in 1.16.5. your code is correct except that it is in the wrong file and don't believe you change the model parts to be the same model parts as yours.
The "main.render' part only applies to my model. "Main' is the name of my model's cube. For you, it'll be "(name of your cube).render" and you'll likely have multiple cubes.
Go to your (name of entity).Java file, it's the same .Java file that you upload when you're uploading a model, and replace the line of code that says this. Here is an image that shows how to get to this file
https://imgur.com/a/KT3sgIC
"@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,"
With "@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
float red, float green, float blue, float alpha) {
poseStack.pushPose();
poseStack.translate(0f, 1.5f - 0.5 * 1.5f, 0f);
poseStack.scale(0.5f, 0.5f, 0.5f);"
After the (part name).render stuff, copy and paste this
"poseStack.popPose();"
Should look similar to this image (the "main.render" to "back_left_left.render" part will be different for you. It'll have the names of your entity models cubes.
https://imgur.com/a/gZKjtM6
Oh ok thanks, I was confused where to put it.
Could one of you guys post your finished codes? I'm a bit confused on where to copy and paste certain things lol
Okay, nevermind. I figured out where to paste the code...
But, whenever I save and load my world, nothing happens. Is there another step or?
@phillipw1954 Make sure the file is locked or else the code you put won't be saved and any changes you made to the code will be reverted back to default.
I'm not sure which model you changed this for. If you haven't already, you make sure you spawn in the model you're changing the scale of. For instance, if you changed a baby model, spawn in the baby model to see if it's size is different.
Also, some of your parts you started capitalized and then the last part "bb_main.render" isn't capitalized. Is your naming scheme just not consistent or is that a typo? Also, I've never used capitalized part names before, so I'm not 100% sure if that'd mess anything up.