5

Is there some way that I could make players invincible to mobs, but still be able to be harmed by players? I have already tried using this command, but it makes the player invincible to other players too. Is there anyway I can do this? Here is the command I tried:

/effect @a 11 240 372000
3
  • This isn't currently possible without creating a plugin. Are you trying to do this with vanilla minecraft or bukkit?
    – user75001
    Apr 30, 2014 at 1:39
  • Nope, this is not possible at the moment. You will need a plugin for that. Why are you trying to do that by the way? Apr 30, 2014 at 6:39
  • @ranger10700 I am trying to do it in vanilla, but thanks for the heads up! I will probably write a plugin... Apr 30, 2014 at 12:12

1 Answer 1

1

Yes, there is a way in the 1.8 snapshots.

Using a RedStone clock give all entities that damage the player a huge weakness effect:

/effect @e[mob id] 18 9999 127

Note that @e targets players and thus so that only mobs get a weakness effect you have to put in an ID for the entity type. You will have to have a few command blocks each for each type of hostile entity(One each for zombies, skeletons, endermen, creepers{change gamerule doMobGriefing to false}, zombie pigmen, ghasts and blazes). This prevents them from doing damage to the player. Note also that if you give them a weakness level of more than 127, it has a negative effect, meaning it will give them basically 127 strength.

Another method that can be used in 1.7.x is giving all the players a resistance effect like you did but weaker, and then giving players a strength effect that overpowers the resistance.
Strength:

/effect @a 5 9999 6

Resistance:

/effect @a 11 9999 4

This will give all players resistance 4 and this is enough to make them invincible to mobs. They will still take hits but will not take any damage. Note: I am not actually sure if Strength 6 is enough to overpower Resistance 4. If it isn't, just give a higher strength. If the Resistance is too low, give them a higher resistance and higher strength. Just look for the balance. :)

A few questions:

  1. Is there a reason you are not making it on Peaceful mode? (I imagine it is so that players don't regenerate health that quickly but you can turn the gamerule naturalRegeneration off)
  2. Is there a reason, if you don't want to turn it to peaceful, why you want to keep gamerule doMobSpawning on?
  3. Are you manually spawning the mobs, i.e. with command blocks? If yes you can modify their attributes to not allow them to damage the player.

So yes, there are ways to do it in vanilla Minecraft.

Hope I helped!

6
  • And actually, you wouldn't have to use a redstone clock if you just set the effect time to something above 372000. Apr 30, 2014 at 22:52
  • And for the reason, I want to make a minigame involving deadly mobs, but I only want the players to be able to be damaged. Apr 30, 2014 at 22:53
  • @user3487713 The reason you have to use a RedStone clock is that if new mobs spawn they won't be given the effect automatically, to give them the effect the command block needs to be activated.
    – SchoolBoy
    Apr 30, 2014 at 22:55
  • And plus I think that even 9999 gives them the effect for an unlimited amount of time...
    – SchoolBoy
    Apr 30, 2014 at 22:57
  • 2
    Just use type=!Player... May 3, 2015 at 23:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .