Jump to content

Hitboxes and size?


Krevik

Recommended Posts

Hi! I've got problem with mob hitboxes. Mob is really big. I set it size using setSize(48F,12F) so as you can see it's huge. Hitboxes shown ingame are ok, but there's problem with hitting it. The mob can be hit only by hitting it in the real center. Hitting borders even if they're in the hitbox range doesn't effect. Is there any way to fix it? https://imgur.com/pITIVs7

Edited by Krevik
Link to comment
Share on other sites

I think it should work. I've done giants and dinosaurs before. The vanilla giant zombie is 6 times regular zombie size and the main part of a vanilla dragon is 16 by 8.

 

There might be a limit though. Maybe start small and increase it a bit at a time to see if there is an actual limit. 

 

I looked through the code a bit. The key bit of code is the EntityRenderer.getMouseOver() method. This is what decides if the player is clicking on an entity. One thing I noticed is that one thing it does it it narrows down the entities to check for using the World.getEntitiesWithinAABBExcludingEntity() method. I looked at that method and it actually has a comment that there is a MAX_ENTITY_RADIUS field that:

     * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
     * Modders should change this variable to a higher value if it is less then the radius
     * of one of there entities.

 

This field is a public static field so is accessible for you. So I think what you need to do is at some time during loading you need to set that field to the size of your entity. 

 

The default is 2. So it makes sense that you might need to change this in your case.

 

Anyway, try that and see if it works.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

7 hours ago, jabelar said:

I think it should work. I've done giants and dinosaurs before. The vanilla giant zombie is 6 times regular zombie size and the main part of a vanilla dragon is 16 by 8.

 

There might be a limit though. Maybe start small and increase it a bit at a time to see if there is an actual limit. 

 

I looked through the code a bit. The key bit of code is the EntityRenderer.getMouseOver() method. This is what decides if the player is clicking on an entity. One thing I noticed is that one thing it does it it narrows down the entities to check for using the World.getEntitiesWithinAABBExcludingEntity() method. I looked at that method and it actually has a comment that there is a MAX_ENTITY_RADIUS field that:


     * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
     * Modders should change this variable to a higher value if it is less then the radius
     * of one of there entities.

 

This field is a public static field so is accessible for you. So I think what you need to do is at some time during loading you need to set that field to the size of your entity. 

 

The default is 2. So it makes sense that you might need to change this in your case.

 

Anyway, try that and see if it works.

Thank you so much jabelar! I think it should work, anyway will try it soon

Link to comment
Share on other sites

On 6/20/2018 at 6:41 AM, jabelar said:

I think it should work. I've done giants and dinosaurs before. The vanilla giant zombie is 6 times regular zombie size and the main part of a vanilla dragon is 16 by 8.

 

There might be a limit though. Maybe start small and increase it a bit at a time to see if there is an actual limit. 

 

I looked through the code a bit. The key bit of code is the EntityRenderer.getMouseOver() method. This is what decides if the player is clicking on an entity. One thing I noticed is that one thing it does it it narrows down the entities to check for using the World.getEntitiesWithinAABBExcludingEntity() method. I looked at that method and it actually has a comment that there is a MAX_ENTITY_RADIUS field that:


     * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
     * Modders should change this variable to a higher value if it is less then the radius
     * of one of there entities.

 

This field is a public static field so is accessible for you. So I think what you need to do is at some time during loading you need to set that field to the size of your entity. 

 

The default is 2. So it makes sense that you might need to change this in your case.

 

Anyway, try that and see if it works.

Tried and it didn't work. Tried puttin World.MAX_ENTITY_RADIUS in entity class, in main class pre init, post init, init methods. Tried setting it to both 12D and 120D. Also tried not using World, but DimensionManager.getWorld(). None of these worked :/ Nothing changed.  Also found out that the problem is only with hitting it with hand/item etc... There is no such problem with arrow. Arrow recognize hitboxes perfectly

Edited by Krevik
Link to comment
Share on other sites

Spoiler

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	World.MAX_ENTITY_RADIUS=12D;
    	OBJLoader.INSTANCE.addDomain(MODID);
    	KetherPacketHandler.init();
    	KCore.instance.dimRegistry();
        //logger = (Logger)event.getModLog();
        proxy.preInit(event);
    }

 

1 minute ago, diesieben07 said:

Show how you tried to change the field. Note: Do not make your own field.

 

 

Link to comment
Share on other sites

20 hours ago, Krevik said:

Tried and it didn't work. Tried puttin World.MAX_ENTITY_RADIUS in entity class, in main class pre init, post init, init methods. Tried setting it to both 12D and 120D. Also tried not using World, but DimensionManager.getWorld(). None of these worked :/ Nothing changed.  Also found out that the problem is only with hitting it with hand/item etc... There is no such problem with arrow. Arrow recognize hitboxes perfectly

 

The fact that arrows work but player hitting doesn't supports my idea that the problem is somewhere in the mouse over method. Once the arrows are flying they use their own collision box to check for collisions. When the player tries to hit something it checks the space around the "look vector" which involves methods like the one I've mentioned.

 

So I still feel the problem can be understood by looking at the EntityRenderer.getMouseOver() method. I'm not certain that radius field is the problem, but it sure sounded like it should be related. Maybe you should use debug mode in Eclipse and set a breakpoint for when user clicks button and step through to see what is happening.

 

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.