How can I make animals unkillable?

Since I showed my 3 year old son the tree house and farm I had built in Minecraft, he has become a huge fan of the game also. At first I would play and he would watch, but now he has started playing himself. I've created a creative world for him and set the difficulty to peaceful. I have built a house and a little farm with wheat, cows, chickens, pigs and sheep. He loves playing farmer.

Unfortunately, as a farmer, he is not always being nice to his animals. He often punches the animals when they are in the way and then the animals die. I would like to be able to make the animals unkillable, because I don't like him killing defenseless animals.

Is there a mod or something that I can use to make the animals unkillable? I have tried searching Google, minecraftforum.net and gaming.se, but I haven't found anything useful yet.


Solution 1:

The solution I can think of is using MCP, which allows you to change the source code of Minecraft (including changing the animals). But if you can't do that, try using these files.

If you have 7zip, open up your minecraft.jar and paste the files inside the zip inside jar. Then delete the META-INF folder inside.

Solution 2:

First, give your player a command block by enabling cheats (ESC->Open to LAN->Cheats=On->Start LAN World) and typing the following command:

/give @p minecraft:command_block

Make sure that you are in creative mode (You can access this with cheats by typing in /gamemode 1)

Now, before doing anything else, make a redstone clock (designs can be found online) and put the command block on the output end (the end sending power)

After that, right click the command block and copy this command with CTRL+C (Command+C for MAC) and paste it into the top line of the command block with CTRL+V (Command+V for MAC):

/entitydata @e[type=!Player,r=500] {AbsorptionAmount:350000000000000000000000000000000000000.0f}

This will make all the animals in a radius of 500 meters (blocks) unkillable. You can't even kill them with /kill @e!

Please note that this is for 1.8.0 and up, so if you have a version below that, you need to upgrade and convert your world (which Minecraft does on it's own). Also, this may cause a bit of lag, and if it doesn't work, try replacing the redstone and comparator with a different redstone clock you can find online.