Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

The anatomy of a Minecraft model

How to work with and create models for Minecraft

To kill an Entity

  • 2013-09-29 19:57:48
    Hi guys. Just been tinkering and I wondered if anyone could tell me how to code my entity so I can 'kill' it with a sword or just by punching it. From the entities I've made, they all seem to be invulnerable to attack, even when I tried implementing damage code from EntityCow. I tried extending EntityAnimal, but the game crashes as it obviously needs something more (other than the baby animal methods). For now I'm just extending Entity. I can kill it with an explosion, but not with a sword. Can anyone help?
  • 2013-09-30 05:43:38
    I think the easiest way to do this will be to extend EntityAnimal instead of Entity. Vswe didn't cover this during the courses so you might want to take a look at the vanilla code or find a tutorial elsewhere.
  • 2013-09-30 05:52:59
    I wouldn't recommend that. If it's not an animal you shouldn't extends Animal.

    I would recommend to give your entity a hitbox (as has been shown in the courses) and override public boolean attackEntityFrom(DamageSource par1DamageSource, float par2). The most basic way of doing it is just to check if you're on the server side and then use setDead();
  • 2013-10-01 12:28:54
    Thanks for the help guys, bit it still won't work. Here is my code: http://pastebin.com/mF1LtdJb
    (The fact it's a turtle is just because it uses a turtle (well, tortoise) model, it's not inherently meant to be a turtle). I can see the bounding box by pressing F3 and B, but when I try to hit it, it just stays there, glaring at me.
  • 2013-10-01 15:01:02
    Never mind! I just didn't include the canBeCollidedWith method. :P Herp derp.
  • Log in or sign up to reply to this thread