0

I'm looking for a solution to solve my problem...

I am currently in the process of creating a Custom Map, called 'Monster Troubles', where (at least) 2-4 players defend their 'house' from being destroyed.
For the mobs to completely destroy the house, one just has to step on a Gold Block where a trigger will occur - then Game Over.

But, some of you may already see a problem here: anyone/anything can trigger the Game Over Sequence.
Which is a big problem, hence why I need Mob-Only-Allowed invisible barriers to surround the Gold Block (and surrounding area).

If anyone has a solution to this and would share, I'd appreciate that greatly.
Thanks

(Note: Focus on the Gold Block surrounded by double_stone_slab's - that's the Game Over Trigger)

![Gold Block = Game Over Trigger ; Cave in the distance spawns Mobs ![House = Main Priority ; Cave spawns Mobs (Secondary Note: The house and cave are aligned with each other, with invisible barrier blocks [minecraft:barrier] - hence why it looked a bit strange.)

6
  • You can't tie the destruction process to the death of a villager? It would be something like "protect the king" or something like that.
    – T. Sar
    Commented Jan 10, 2017 at 19:11
  • @TSar I am not using an entity to end the game. Instead, a mob has to step on to the Gold Block to trigger Game Over. And that's why I need to Mob-Only-Allowed barriers to stop players from ending the game themselves. Commented Jan 10, 2017 at 19:41
  • Can't you improve your command block contents to make them detect only mobs? Commented Jan 10, 2017 at 20:45
  • @TSar I followed your Suggestion and it worked. Instead of having a Gold Block be the Game Over Trigger, it's a Villager. I was first apprehensive of the idea if I'm honest, but thanks for suggesting! Commented Jan 13, 2017 at 18:00
  • 1
    @HolyBlackCat I have instead rigged a set-up to detect when a Villager, being the Main Objective, dies. If it does die, the Game-Over Sequence Occurs. Thank you for the idea though. Commented Jan 13, 2017 at 18:01

2 Answers 2

3

The solution is not to construct a player-proof barrier, but to make the end game trigger only respond to mobs. I presume that you are using command blocks. Put this command in a command block:

execute @e[type=Zombie] ~ ~ ~ testforblock ~ ~-1 ~ minecraft:gold_block

Set the command block to repeat mode, unconditional, and always active. Put a comparator facing out of the command block. When a zombie stands on a gold block, the comparator will activate until it steps off. If there is more than one zombie, then the command will activate for any zombie. It does not activate for players or other mobs.

Then, just add a command block for every monster in the game.

Alternatively, if you want to command to be able to be triggered by any entity apart from players, simply use this command instead:

execute @e[type=!Player] ~ ~ ~ testforblock ~ ~-1 ~ minecraft:gold_block

Tested and working in Minecraft 1.11.2

2
  • Thanks! Genius method too (I really should have had thought of it, but eh)! :D Commented Jan 11, 2017 at 17:43
  • 1.13 syntax: /execute at @e[type=<zombie|!player>] if block ~ ~-1 ~ gold_block run <chained command>
    – pppery
    Commented Jul 31, 2019 at 1:14
-1

Perhaps try the opposite solution to cloud's excellent answer: rather than allow anything to be there and only respond to some, why not tp away anything that doesn't fit your criteria?

/tp @e[type=item,type=player,type=...

3
  • This doesn't work.
    – pppery
    Commented Jul 31, 2019 at 1:14
  • @pppery It worked in 2017. Have they changed the way these commands work in more recent versions? It’s been a while since I’ve played Minecraft.
    – DonielF
    Commented Jul 31, 2019 at 1:37
  • Well, I haven't tested it, but I don't thing combining multiple identical selectors into one ever worked. 1.13 did, however, make it fail more loudly.
    – pppery
    Commented Jul 31, 2019 at 1:40

You must log in to answer this question.

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