Jump to content

[1.12.2] Changing entity hitbox after it has been spawned


Recommended Posts

Posted

Hey folks,

I'm trying to implement a special type of wolf (a direwolf, from the ASOIAF universe) with four different growth stages. First and foremost, these stages change the rendered size of the wolf. I've got this part working already with:

@Override
protected void preRenderCallback(EntityDirewolf entityDirewolf, float b) {
    // the size of a direwolf is influenced by its stage of growth
    // at stage one, a direwolf is the same size as a normal wolf
    // at stage four, a direwolf is twice as large in every dimension
    float modifier = (entityDirewolf.getGrowthStage() / 3f) + (2f / 3f);
    GL11.glScalef(modifier, modifier, modifier);
}

The issue I'm struggling with is scaling the hitbox itself in line with the larger model.

Before I implemented variable stages of growth, I scaled the hitbox in the direwolf's constructor, like so:

public EntityDirewolf(World worldIn) {
    super(worldIn);
    setSize(1.45f, 2.0f);
}

This worked fine. However, I would like to manipulate after the direwolf object has already been instantiated.

From my testing, simply using...

Entity#setSize()

...after the direwolf had been spawned with...

// make a fun cuddly direwolf
EntityDirewolf direwolf = new EntityDirewolf(player.getEntityWorld());
direwolf.setPosition(player.posX, player.posY, player.posZ);
player.getEntityWorld().spawnEntity(direwolf);

...did not do anything.

From my searching on the forums, it seems like newer versions of Forge have a 'recalculateSize()' method that might solve this problem. Unfortunately, I don't think it exists in the older version of Forge I am using, and upgrading isn't possible at this time.

Is there a way to rescale an entity's hitbox on the fly, after said entity has been spawned?

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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