Posted June 9, 201312 yr I want to add a custom hitbox for my mob. Not this BoundingBox to define when the mob is been pushed but the hitbox which defines when the mob is being damaged. I think nobody needs more to know? In advance Me
June 9, 201312 yr The bounding box is the hitbox. Minecraft doesn't distinguish between them as far as I know. For blocks there's a separate bounding box (where the player runs into it) and hit box (where the mouse can highlight the block), but this has to do with blocks that the player can walk through needing a collision box for interactions separate from the physics. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 9, 201312 yr Author So I just override getBoundingBox() ? cause I tried that out and it did nothing... : @Override public AxisAlignedBB getBoundingBox() { return AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); }
June 9, 201312 yr No idea. All I know about is this.setSize(width, height); Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 9, 201312 yr I don't think it will work if you pass 0 to every argument. I also think there's another function you need to override: getCollisionBox(Entity). Alternatively, you could try modifying the field this.boundingBox. I'd be glad to help, though, as I need the answer to this problem myself. BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 10, 201312 yr Author Right at the start: this.boundingBox is final I didn't know the getCollisionBox() method so I will try it After trying it out I'm gonna report the result in this thread.
June 10, 201312 yr Author Okay, I've found critical point of code that leads us to no control over this thing...: EntityRenderer: line 304ff. float f2 = entity.getCollisionBorderSize(); -> AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double)f2, (double)f2, (double)f2); MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32); if (axisalignedbb.isVecInside(vec3)) { if (0.0D < d2 || d2 == 0.0D) { this.pointedEntity = entity; d2 = 0.0D; } } else if (movingobjectposition != null) { double d3 = vec3.distanceTo(movingobjectposition.hitVec); if (d3 < d2 || d2 == 0.0D) { this.pointedEntity = entity; d2 = d3; } } This leads us to the problem. As a modder I don't know how to influence the entity.boundingBox as it is declared final in Entity... I am not used to make a request so if one of you is more experienced in requesting something from the dev-team, pls do it. All they have to do is to swap this special line of code from entity.boundingBox to entity.getBoundingBox() or entity.getCollisionBox(). Either of them would do fine.
June 10, 201312 yr The entity.boundingBox is final, but you can alter it in your constructor. As a standard, it's initialized with an AABB with "no box" (look at Entity.java, line 253) So if you don't alter it, you can just override getCollisionBorderSize() and return anything you wish. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
June 10, 201312 yr Or: this.boundingBox.setBounds(minX,minY,minZ,maxX,maxY,maxZ); BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 10, 201312 yr Author So I did this: public EntityFelyne(World par1World) { super(par1World); this.boundingBox.setBounds(0D, 0D, 0D, 0D, 0D, 0D); } @Override public AxisAlignedBB getCollisionBox(Entity par1Entity) { return boundingBox; } @Override public AxisAlignedBB getBoundingBox() { return boundingBox; } Still, when I enter debug mode.... box[-33.80000001192093, 66.0, 140.19999998807907 -> -33.19999998807907, 67.79999995231628, 140.80000001192093]; and this is totally the zone I can hit the entity in. Anything you wanna say about this?
June 10, 201312 yr So I did this: public EntityFelyne(World par1World) { super(par1World); this.boundingBox.setBounds(0D, 0D, 0D, 0D, 0D, 0D); } @Override public AxisAlignedBB getCollisionBox(Entity par1Entity) { return boundingBox; } @Override public AxisAlignedBB getBoundingBox() { return boundingBox; } Still, when I enter debug mode.... box[-33.80000001192093, 66.0, 140.19999998807907 -> -33.19999998807907, 67.79999995231628, 140.80000001192093]; and this is totally the zone I can hit the entity in. Anything you wanna say about this? You're setting all the bounds to 0... it seems doubtful that that would work... Also, apparently setPosition(x,y,z) changes the bounding box... according to the "width" and "height". So you'll have to override that too. BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 10, 201312 yr Author I've overridden setPosition: /EDIT wrong solution: @Override public void setPosition(double par1, double par2, double par3) { AxisAlignedBB b = this.boundingBox; double minFromPosx = this.posX - b.minX; double minFromPosy = this.posY - b.minY; double minFromPosz = this.posZ - b.minZ; double maxFromPosx = b.maxX - this.posX; double maxFromPosx = b.maxY - this.posY; double maxFromPosx = b.minZ - this.posZ; this.posX = par1; this.posY = par2; this.posZ = par3; this.boundingBox.setBounds(posX - minFromPosx, posY - minFromPosy , posZ - minFromPosz, posX + maxFromPosx, posY + maxFromPosy, posZ + maxFromPosz); } it doesn't really work at all... Now I have weird glitches were the entity is not where it belongs to and I can't really explain why EDIT: fixed it, works fine now EDIT2: I did not tell the truth... it does not work all the time... will inspect that EDIT3: finally... I found a solution to keep the boundingBox centered on your entity (at least x and z -axis). No more wishes I guess: @Override public void setPosition(double par1, double par2, double par3) { AxisAlignedBB b = this.boundingBox; double boxSX = b.maxX - b.minX; double boxSY = b.maxY - b.minY; double boxSZ = b.maxZ - b.minZ; this.boundingBox.setBounds(posX - boxSX/2D, posY, posZ - boxSZ/2D, posX + boxSX/2D, posY + boxSY, posZ + boxSZ/2D); }
June 10, 201312 yr So, it works completely now? Right? Or is it still broken? BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 10, 201312 yr Author Works all fine, I tested it and I found no glitches/bugs or anything If YOU find and don't fear to post them, I'll see what I did wrong. Also a non-centered BB would be easy with 3 new vars (I am sure you know how to if youu know a bit of prgramming).
June 10, 201312 yr Thanks given! Now I just need to figure out how to control my entity with the keyboard... BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
April 28, 20205 yr so i am pretty new at coding and I really want to implement this in my mod, but I don't understand what I should put in for all the Variables
April 29, 20205 yr 4 hours ago, java coder123 said: so i am pretty new at coding and I really want to implement this in my mod, but I don't understand what I should put in for all the Variables this is a post from 7 years ago, use the latest versions of Forge and start your own thread. And if you don't know Java, learn that first before diving into Forge, this isn't a forum for learning Java.
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.