Posted August 9, 201411 yr Hey guys, I'm having some trouble to update my mob hit box. I created a custom growth system (which is working fine), so I can't use the vanilla class. I tried using the setSize() method, but it doesn't seem to work: public void setCreatureSize(float xzSize, float ySize) { System.out.println("xzSize: " + xzSize + " ySize: " + ySize); super.setSize(xzSize, ySize); } How can I change/update the hitbox of a mob?
August 9, 201411 yr Why do you think it doesn't work? the setSize() method (assuming your class is an extension of something in the Entity class hierarchy is the right method -- you can check the source and it changes the boundingBox. By the way, if you press F3+B while playing the game, it will make all the entity hitboxes visible. I recommend this whenever people are making custom models or otherwise mucking around with hitboxes so you can see what is really going on. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 9, 201411 yr Author I don't know why, but the boundingBox doesn't change... Do I need something like a datawatcher for this?
August 9, 201411 yr Did you make sure that your call to setSize runs after the vanilla call to set size? IIRC, setSize has some side effects, so you might just want to override it anyway. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
August 9, 201411 yr Author I found my mistake! I was using the client side of the onUpdate() method to run the super.setSize(). I should have called it on the server side of the living update, just like vanilla!
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.