Jump to content

Recommended Posts

Posted

Google revealed to me that a few modders were having issues with setting the bounding box for custom entities.

 

I played around with it for a while and I figured out. This is for those that happen to need and answer and find this thread.

 

 

The bounding box is an AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ) type.

 

The catch is, and where most people seem to be getting confused, is that the these values are not offsets from the center of the entity. These are global world coordinates.

 

So what we would think would be boundingBox(-1, 0, -1, 1, 2, 1), assuming the box is at global coords (350, 75, 670) should really be boundingBox(350 - 1, 75 - 0, 670 - 1, 350 + 1, 75 + 2, 670 + 1).

 

So your final script should look something like this:

 

import net.minecraft.entity.Entity;

 

class myEntity extends EntityLiving {

 

//No local boundingBox variable. The game won't use it.

 

double minX = -1 //this is the left/right direction

double minY = 0 //this is the up/down direction

double minZ = -1 //this is the forward/back direction

double maxX = 1 //this is the left/right direction

double maxY = 2 //this is the up/down direction

double maxZ = 1 //this is the forward/back direction

//this will produce a (2x2x2) bounding box that sits flat on the ground.

 

public myEntity (World par1World, double par2, double par4, double par6) {

 

super(par1World);

 

this.boundingBox.setBounds(par 2 - minX, par4 - minY, par6 - minZ, par2 + maxX, par4 + maxY, par6 + maxZ);

 

}

 

//Not done yet

 

    @Override

    public AxisAlignedBB getCollisionBox(Entity par1Entity)

    {

    return par1Entity.boundingBox;

    }

 

    @Override

    public AxisAlignedBB getBoundingBox()

    {

        return this.boundingBox;

    }

 

    public boolean canBeCollidedWith()

    {

    return !this.isDead;

    }

}

 

//Note this code has NOT been tested nor will I help anyone debug it.

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.