Jump to content

[1.13.2] Empty space beneath Entity model that scales with rendered Entity's scale


TheKingElessar

Recommended Posts

EDIT: I'VE DECIDED THIS DOESN'T HAVE TO DO WITH THE EYE HEIGHT LIKE I SAID IN THIS OP, SO GO TO THIS POST IN THIS THREAD TO SEE THE LATEST DETAILS: 

 

 

I'm trying to spawn an Entity at a Player's eye height. Here's the y-level I'm trying to use:

player.posY + (double)player.getEyeHeight() - (double)0.1F

That's pulled directly from a constructor in the EntityArrow class.

 

However, it's spawning the Entity way too high. If I replace the above statement with 0.95 it spawns at pretty much exactly eye level, but the eye level of a Player is supposedly 1.62 everywhere I look (Gamepedia, EntityPlayer::getEyeHeight and ::getDefaultEyeHeight, etc.).

 

The Entity I'm spawning is custom - could this problem have something to do with my model (which is why it appears higher), or is there something I'm not understanding about the eye height of a Player?

Edited by TheKingElessar
Link to comment
Share on other sites

5 hours ago, 0xx06 said:

pretty sure it's relative eye level in relation to size (0.0-1.0), 0.0 being lowest point and 1.0 top of the head.

I don't think that's the case because a Player's eye height is normally 1.62.

 

I played around with my entity some more, and now I'm confident it's related to my model or the entity rendering. The larger I set its scale (ModelRenderer::render), the higher it is. I think there must be some empty space beneath it that for some reason is part of the model. Here's my model class, can anyone provide some insight into why it's doing this?

@OnlyIn (Dist.CLIENT)
public class ModelMyEntity extends ModelBase
{
    private final ModelRenderer main;
    private final ModelRenderer nose_pyramid;
    private final ModelRenderer main_body;
    private final ModelRenderer tail_pyramid;
    
    public ModelMyEntity() {
        textureWidth = 64;
        textureHeight = 64;
        
        main = new ModelRenderer(this);
        main.setRotationPoint(0.0F, 24.0F, 0.0F);
        
        nose_pyramid = new ModelRenderer(this);
        nose_pyramid.setRotationPoint(0.0F, 0.0F, 0.0F);
        main.addChild(nose_pyramid);
        nose_pyramid.cubeList.add(new ModelBox(nose_pyramid, 24, 33, -1.5F, -1.5F, -6.75F, 3, 3, 1, 0.0F, false));
        nose_pyramid.cubeList.add(new ModelBox(nose_pyramid, 6, 42, -0.5F, -0.5F, -7.75F, 1, 1, 1, 0.0F, false));
        
        main_body = new ModelRenderer(this);
        main_body.setRotationPoint(0.0F, 0.0F, 0.0F);
        main.addChild(main_body);
        main_body.cubeList.add(new ModelBox(main_body, 0, 14, -1.5F, -2.5F, -5.75F, 3, 1, 11, 0.0F, false));
        main_body.cubeList.add(new ModelBox(main_body, 28, 0, -1.5F, 1.5F, -5.75F, 3, 1, 11, 0.0F, false));
        main_body.cubeList.add(new ModelBox(main_body, 0, 28, 1.5F, -1.5F, -5.75F, 1, 3, 11, 0.0F, false));
        main_body.cubeList.add(new ModelBox(main_body, 28, 14, -2.5F, -1.5F, -5.75F, 1, 3, 11, 0.0F, false));
        
        tail_pyramid = new ModelRenderer(this);
        tail_pyramid.setRotationPoint(0.0F, 0.0F, 0.0F);
        main.addChild(tail_pyramid);
        tail_pyramid.cubeList.add(new ModelBox(tail_pyramid, 24, 28, -1.5F, -1.5F, 5.25F, 3, 3, 2, 0.0F, false));
        tail_pyramid.cubeList.add(new ModelBox(tail_pyramid, 0, 42, -0.5F, -0.5F, 7.25F, 1, 1, 2, 0.0F, false));
    }
    
    @Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
        main.render(f5);
    }
    public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;
    }
    
}

 

Edit: The model was made with BlockBench.

Edited by TheKingElessar
Link to comment
Share on other sites

 
 
 
 
 
 
1 hour ago, 0xx06 said:

you know what relative relationship means though right? 

An Entity has a total height value. It also has an eye height value. I took what you said to mean that the eye height value is a percentage of the total height value. So, if an Entity's height is 10, and it has an eye height of .6, the Entity's eye height would be 60% of 10 (which of course is 6). However, that wouldn't make sense when the Entity's eye height is greater than 1, which the EntityPlayer's is (when standing it's 1.62).

 

So, to try and reconcile this, I just looked at some other Entities. This may look like a long post, but it's nothing complicated. If you don't want to look at this you can skip to the end!

 

It seems that EntitySheep uses a relative height.

public float getEyeHeight() {
   return 0.95F * this.height;
}

 

EntityZombie uses a hard-coded one that depends on whether or not it's a child:

public float getEyeHeight() {
   float f = 1.74F;
   if (this.isChild()) {
      f = (float)((double)f - 0.81D);
   }

   return f;
}

 

EntityEnderman is hard-coded even simpler:

public float getEyeHeight() {
   return 2.55F;
}

 

EntityPig doesn't override the getEyeHeight method from Entity, so it uses the default one in Entity, which is a relative one:

public float getEyeHeight() {
   return this.height * 0.85F;
}

 

Finally, EntityPlayer is much more complicated because of all the ways Player heights change:

private float eyeHeight = this.getDefaultEyeHeight();

public float getDefaultEyeHeight() {
   return 1.62F;
}

public float getEyeHeight() {
    float f = eyeHeight;
    if (this.isPlayerSleeping()) {
        f = 0.2F;
    } else if (!this.isSwimming() && !this.isElytraFlying() && this.height != 0.6F) {
        if (this.isSneaking() || this.height == 1.65F) {
            f -= 0.08F;
        }
    } else {
        f = 0.4F;
    }
    
    return f;
}

An Entity's height is set using Entity's setSize method. Normally, for the EntityPlayer, it's 1.8F.

 

Which means that the hardcoded eye height value of 1.62F should work for my purposes!

 

Since it doesn't, I can only assume that it has something to do with my model or rendering, because of what I mentioned earlier:

2 hours ago, TheKingElessar said:

I played around with my entity some more, and now I'm confident it's related to my model or the entity rendering. The larger I set its scale (ModelRenderer::render), the higher it is. I think there must be some empty space beneath it that for some reason is part of the model.

 

However, I can't see anything wrong with my rendering/model classes. I'll rename the question now that I have a better idea what's going on (or if that isn't possible I'll make a new one.).

Link to comment
Share on other sites

If you turn on debug housing boxes, does the bounding box match up with the model?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

That’s your problem then

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

  • 2 weeks later...

What I have found from my own experimentation (and I hope someone will correct me if I'm wrong) is that model rendering space starts 24 units above the y location of the entity and goes up as you go down, so the origin would be at 0 and 24 would be at the y location (thus you are rendering from the top down).  Entity height (as defined in your EntityEntry) is defined from bottom up.  Eye height measures from y location up, and is usually defined as a percentage of entity height (but can also be defined as an absolute)

 

Hope this helps.

/P

Link to comment
Share on other sites

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.