Skip to main content

Programming a world to automatically switch student's game modes when they enter a certain area

Comments

14 comments

  • Andrew L

    Hi there James Myklebust-Hampshire!

    That sounds like an awesome project! I bet your students will have a lot of fun with it. Using command blocks, you should be able to set areas within a certain radius to adventure mode. This will prevent students from destroying anything without a tool that has been given to them with the specific ability to destroy objects.

    I've provided a link below to two resources that have a list of the commands required to do this:

    https://minecraft.gamepedia.com/Commands

    https://minecraft.gamepedia.com/Commands/gamemode

    I hope these help!

    0
  • Thanks - I am excited to get started with it.

     

    Thank you for the links, but I am still struggling to program the block. As I want anyone within a 30 block radius to switch to adventure mode, I am using: /gamemode adventure @a[distance=1..30]

    Error messages keep coming up though. 

    Would appreciate some more help if possible!

     

     

     

    0
  • Chris Fuge
    Beacon of Knowledge

    /gamemode a @a [r=30]
    And you’ll want to make it a repeating command block so it keeps working. But then you will need another command block to put them back on survival mode...

    Have you considered just putting deny blocks underground in the areas you want protected? You can use /fill to quickly place them at a later underground. I can explain it more if you think that would work for you.

    0
  • Hi Chris,

    Thanks for this - a much easier piece of code that makes more sense than what is listed on the commands page!

    I haven’t explored the deny blocks and other special blocks - this will probably need to be my next piece of Minecraft learning (it’s been a steep curve).

    For this project, I think I will make the first lever (which allows access to a room with a trapped chest) to also run to a command bleach which switches all their modes. Then the final level which allows the trapped member to escape runs to a command block which switches modes back (and summons a zombie or two).

    Does this sound like a reasonable solution?

    If you could also help me out with the other special blocks I’d be more than happy!

    0
  • Chris Fuge
    Beacon of Knowledge

    James, it sounds like the solution above would work fine, as long as everyone is close enough to the command block when its activated. If a student in the group was out of range it may not change their gamemode...

    The Deny block works just like adventure mode, but only for any blocks above it (at any height). Players can still interact with things like chests, levers, buttons... they just cant break anything. Deny blocks can be found by clicking on the plus on the red border block to view all three "permission" blocks. The grey and black on is the Deny. 

    I would use the /fill command and select two opposite corners of the area you do not want students to break. Then type the following into the chat bar:

    /fill x1 y1 z1 x2 y2 z2 deny

    x1 y1 z1 would be the coordinates for the first corner of the area and x2 y2 z2 would be the coordinates for the opposite corner. I would also set both the y values for a few blocks underground, so subtract 2 or 3 from the middle number of your coordinates. You may need to turn on "show coordinates" in the settings.

    1
  • Chris Fuge
    Beacon of Knowledge

    Also, if this is your first time using /fill you may want to export your world first just in case you type something wrong.

    /fill can be an awesome tool to do things quickly, but it can also easily wipe out everything if you type a number wrong...

    1
  • Caleb Waller

    On the above where you mentioned setting another command block to set players back to Survival, how would I go about doing that?

    0
  • Chris Fuge
    Beacon of Knowledge

    Caleb, it depends a lot on how your world is setup, but you could just put a second command block in the new area. You could either have a button/lever/pressure plate to activate it, or you could set it as repeat and always active. Make sure you add a distance to the target selector so it only changes gamemode for players in a certain radius. For example:

    /gamemode s @a [r=10]

    This would put all players within 10 blocks of the command block on survival mode.

    You would just need to make sure it’s in a place that they have to pass by.

    0
  • Thanks! I I will play around with the /fill command on another world and see how it goes. I think my current plan will work - I set a /testfor repeater connected to another block which sets all players in the area (and anyone who walks through that particular door) to adventure mode. 

    I then have a lever which works a piston, allowing the trapped player to escape - this is also connected to a command block which sets all players in the area back to survival and also spawns a couple of zombies. 

    It is good to know about the barrier blocks though, as next time I can start with this and not worry about having certain levers etc.

    Appreciate the help!

    0
  • I am now having some issues with the command block to summon a zombie (or any mob for that matter). I have wired it up to the same lever that releases the trapped player and returns the gamemode to s. 

    I am using /summon Zombie but this gives the error message "Could not summon object". I have tried adding coordinates but no luck there either. Have been YouTubing and reading but can not find the fix!

    0
  • Merry Hofmeister
    Beacon of Knowledge Super Star Moderator

    James Myklebust-Hampshire - does the game happen to be in Peaceful mode? 

    0
  • Chris Fuge
    Beacon of Knowledge

    Merry Willis, I have done that before!

    You might also have mobs disabled in the settings. If you scroll all the way down and click on "Show classroom settings" (right before Copy, Export, Delete), there are additional options, one of them being "Allow Mobs". Make sure that is on.

    0
  • Thanks, peeps! I will try these a little later today and get back to you :)

    0
  • Yep...it was on peaceful! Thanks :)

    0

Please sign in to leave a comment.