So I'm just trying to protect my house by using a /testfor
to test for a player, and /effect
clear them.
All I have seen is people talking about scoreboards, but I don't want to make a scoreboard for just my house. Is it possible to make scoreboards that either doesn't exist (so other scoreboards can be made) or just make the scoreboard invisible?
2 Answers
Scoreboards are just places to store numbers, you can make multiple scoreboards and they're not shown anywhere on default.
More info can be found on the Minecraft Wiki
The use of a scoreboard is specifically to display information to the player, using the command:
/scoreboard objectives setdisplay (Objective) (DisplaySlot)
where the display slot is the sidebar. Any objectives that you make by default don't display there automatically. This means that if you use the dummy type of scoreboard then unless you set it to the sidebar then it wont appear.
Here is a simple set of commands that should do what you want although you didn't specify which players to testfor or effect so I assumed you wanted all in a range of your house to be unable to do anything.
First create an objective that indicates if someone is in range:
/scoreboard objectives add (Name Of Objective) dummy [There is no need for a display name here]
Then place these commands in command blocks set to the modes repeat and always active rather than impulse and needs redstone: /scoreboard players set @a[r=(Distance), name=!(Name)] (Name Of Objective) 1 /scoreboard players set @a[r=!(Distance), name=!(Name)] (Name Of Objective) 0 Distance is the distance from the command block that you want to protect.
Then in some more infinitely running command blocks place these commands, it is best that these also go in your house or in the spawn chunks so they are loaded. Use one of the two sets of commands, the first uses the gamemode of the player and the other uses the effect method that you first described:
Method One:
/gamemode adventure @a[score_(Name Of Objective)=1, score_(Name Of Objective)_min=1] /gamemode survival @a[score_(Name Of Objective)=0, score_(Name Of Objective)_min=0]
Method Two:
/effect @a[score_(Name Of Objective)=1, score_(Name Of Objective)_min=1] mining_fatigue 5 100 /effect @a[score_(Name Of Objective)=0, score_(Name Of Objective)_min=0] clear
The issue with method two is that the player can place blocks still but can't break any blocks whatsoever The second command is for instantaneous potion clearing but doesn't allow anyone to have any potion effects outside your house. Method one will automatically put everyone on survival the moment they leave regardless of their original gamemode.
There are more complicated systems that can be used to accomplish this without the side effects although they would take ages to explain here and the instructions would be far to complicated.