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:
- 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)
- Is there a reason, if you don't want to turn it to peaceful, why you want to keep gamerule doMobSpawning on?
- 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!
You can use a filtered /clone
command that will copy blocks to their same position. The result is no difference visually, but the command can return a CommandStat value depending on its success.
Prerequisites:
Objective to hold the returned CommandStat value.
/scoreboard objectives add BLOCKS dummy
Applying the AffectedBlocks
trigger to players, so that when they run commands, their own "BLOCKS" score will be set equal to the number of blocks affected. You may need this on a clock if new players can join at any time.
/stats entity @a set AffectedBlocks @a[c=1] BLOCKS
In order for CommandStats to modify a target's score, they must be tracked on the scoreboard prior. This may need to be on a clock as well.
/scoreboard players add @a BLOCKS 0
Clock commands:
The following must be run in order on a clock.
Cause players to run a /clone
command around them, looking for grass specifically. It will be cloned to the same position that they're already in. This will return either the number of grass blocks found or 0. The target coordinates should be the same as the first specified corner.
/execute @a ~ ~ ~ /clone ~-10 ~-1 ~-10 ~10 ~10 ~10 ~-10 ~-1 ~-10 filtered force minecraft:grass
Players with a "BLOCKS" score of 1+ has grass around them. You can target them based on this value.
/say @a[score_BLOCKS_min=1] has grass blocks around them.
/say @a[score_BLOCKS_min=10] has at least 10 grass blocks around them.
Best Answer
You could use the /effect command to apply slowness to every entity with a really high level and time as such:
Then when you detect your player in the boat (this is where my knowledge ends), you can clear the effect as such: