Any way to create an animal/mob corpse?

How can I create an entity, that will have a model of lying mob and won’t despawn some time?
I need to create it after any mob dying. The “carcass” must exist for some time that it was possible to cut and skinned, for example.
It will to be good, if this entity would have any custom properties. For example, the freshness, wich will be depend on a time.

sorry for errors, I’m not english speaking

If you spawn a mob, kill it but then prevent it from despawning after death, you can force a corpse to remain there but it won’t necessarily behave nicely 100% of the time.

Will try this, but I don’t like too, that this would be a dead mob. It would be better if it will be alive mob with the changed behavior.

I seriously doubt you could convince the client that a mob was dead with it being alive without some crazy packet magic.

Seems like you could spawn a Human Entity and set the pitch and yaw. Haven’t spent a lot of time messing with Entity’s but seems like it be possible.

As I understand, I can’t change the entity model, because the client chooses the model depending on the type of entity.
But can I create an alive mob, wich not moves (disable any behavior at all) and rotated roll by 90 degrees?

But what about the roll?

setLocationAndRotation allows to use a Vector3d to set pitch(x) yaw(y) and roll(z)

Doesn’t that just handle the head?

Like I said I haven’t done much messing around with entities so I’m not sure but I’ve used that method in ProjectPortals to set the direction player faces on teleport and seems to work on the whole Player in my situation. There’s also setRotation which I believe has the same results but without settings a new Location. Just have to play around with it and find out

It does. On setRotate(0,90,0) the sheep is looking into itself :grinning:

Just as I suspected. Yeah, you’re going to want to kill it.

Ok. How can I prevent died mob despawn? I guess it may be only client-side mechanics, and from server just comes “killed” message, so on the server this mob already doesn’t exist. No?

appositely, I even doesn’t found how to kill it… -_-

Sorry, I’m absolutely new in minecraft plugins/mods creating. I’m a PHP/Js/Python web developer with experience, but I have poor java knowledge (I learned java 6, web sockets, servlets etc…). And low level of english is difficult to read documentation.

I’ve taken a look at the internal minecraft code for this.
In EntityLivingBase there’s a field called deathTime which is exactly what you want, it’s description is:

The amount of time remaining this entity should act ‘dead’, i.e. have a corpse in the world.

It’s used both on the server and the client when an entity’s health drops to 0 or below.

The problem from what I can see is that there’s no way to control the client’s deathTime from the server as they’re not sync’d.
I’d have to experiment somewhat but I think you may be able to trick the client into activating the death sequence (deathTime is a part of that). But keep the health balanced above 0. Not sure though.

1 Like

So… I’m watched events on a server runtime and kill some sheeps. Server have no event about entity despawn after its death. Server have only entity die event, and then on client sheep is dissapeared. Entity death = entity despawn. The problem becomes more difficult. :c

But I found a BodyPartRotationalData, which holds the information about rotate of each part of the body and have a setters for each one. Maybe, it can resolve my problem.

you need to cancel the entity despawn event.
see here

The DestructEntityEvent is not cancellable. Note if it were, there may be undefined behaviour.

The entity renderer does not always take into account the 3 axis of rotation of an entity.
The base entity renderer RenderLivingBase only takes into account the yaw component, it is not possible to render entities on other axis’ unless you exploit vanilla renderer behaviours (e.g. naming an entity Dinnerbone rotates the pitch by 180).
In some cases rotation can make a difference, for example each component of an armor stand can be rotated freely which is what BodyPartRotationalData allows you to do.

1 Like

I actually made a corpse plugin a while ago for craftbukkit. You can start the dead animation and then send a health packet (> 0) to stop the animation. That way the animation will stop at the exact point in the animation, the animation may fail if there are latency issues and bodies of spiders and such rotate into the ground (default mc). At least this worked in 1.7.10
You won’t be able to do this alone with the sponge api though, it would require some tinkering with the internals.
I might take a look at it again when I have some more time.

EDIT: Found some old screenshots: (03/03/2014)

1 Like