[Suggestion] MineCraftSweeper on Games Server

Discussion in 'Suggestion Box Archives' started by PatchesMasterBlk, Aug 24, 2017.

?

Should this be added to the /games server?

Yes 6 vote(s) 100.0%
No 0 vote(s) 0.0%
  1. Minesweeper in Minecraft: A 50x50 square of grass blocks, a player digs down to find either:

    a sign with a number 1-8 showing how many TNT blocks (mines) are ajdacent to that block

    or a TNT block/mine, causing an explosion and game over.

    Each 50x50 square would be generated with 15 randomly placed mines.

    If a player knows where a mine is, they can put a red banner on that block.
  2. Interesting idea, it seems like it would be pretty fun!
    +1
  3. Rather interesting suggestion, inspired me to create a proof of concept... :)
    Before I show it off, it took about 5-6 days to complete. It could have been done quicker, but I needed a few breaks in between. Also I used minecraft functions instead of Java as I have not learned the language just yet. Now before you ask, yea I could have used command blocks, but I think they would be less efficient in this case.

    With that said, the proof of concept is in the spoiler below...
    Prerequisites...
    Code:
    #Run the following commands once
    #   /gamerule logAdminCommands false
    #   /gamerule commandBlockOutput false
    #   /gamerule gameLoopFunction minesweeper:main
    #   /scoreboard objectives add MineSweeper dummy
    #
    #The following area_effect_cloud must always be loaded
    #   /summon minecraft:area_effect_cloud ~ ~ ~ {"Duration":2147483647,"Tags":["placeholder"]}
    #
    #Items
    #   /give @p spawn_egg 1 0 {"EntityTag":{"id":"minecraft:squid","Tags":["squidfield","detect"]},"display":{"Name":"Detector"}}
    #   /give @p spawn_egg 1 0 {"EntityTag":{"id":"minecraft:squid","Tags":["squidfield","smallsquid"]},"display":{"Name":"Small Field"}}
    #   /give @p spawn_egg 1 0 {"EntityTag":{"id":"minecraft:squid","Tags":["squidfield","mediumsquid"]},"display":{"Name":"Medium Field"}}
    #   /give @p spawn_egg 1 0 {"EntityTag":{"id":"minecraft:squid","Tags":["squidfield","largesquid"]},"display":{"Name":"Large Field"}}
    The Files...
    Each code block from now on represents one file, I'll tell you what each file needs to be named as we go. Each file should be put inside of the following directory:
    C:\Users\"User"\Appdata\Roaming\.minecraft\saves\"YourWorld"\data\functions\minesweeper

    The following file should be named "main.mcfunction".
    Code:
    #Sets the amount of block updates allowed in this tick
       scoreboard players set #bpt MineSweeper 10
    
    #Sets the amount of mines that will be placed in the minefield
       scoreboard players set #mines MineSweeper 10
    
    #Runs the ".mcfunction" files
       execute @e[type=minecraft:squid,tag=squidfield] ~ ~ ~ function minesweeper:setup
       execute @r[type=minecraft:area_effect_cloud,tag=placed] ~ ~ ~ function minesweeper:game
       execute @e[type=minecraft:area_effect_cloud,tag=placemines] ~ ~ ~ function minesweeper:setupfield
    The following file should be named "setup.mcfunction".
    Code:
    #Summons needed entities and kills squid running function
       execute @s[tag=detect] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[tag=smallsquid] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {"Duration":2147483647,"Tags":["smallfield","placemines"]}
       execute @s[tag=mediumsquid] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {"Duration":2147483647,"Tags":["mediumfield","placemines"]}
       execute @s[tag=largesquid] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {"Duration":2147483647,"Tags":["largefield","placemines"]}
       tp @s ~ -200 ~
    The following file should be named "game.mcfunction".
    Code:
    #Decrements score until this function is not allowed to run next tick...
       scoreboard players remove #bpt MineSweeper 1
    
    #Counts How many mines are around area_effect_cloud. If mine is directly below area_effect_cloud, Minesweeper will = 9
       scoreboard players set @s MineSweeper 0
       execute @s ~ ~ ~ detect ~1 ~-2 ~1 minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~1 ~-2 ~ minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~1 ~-2 ~-1 minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~ ~-2 ~-1 minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~ ~-2 ~1 minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~-1 ~-2 ~-1 minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~-1 ~-2 ~ minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~-1 ~-2 ~1 minecraft:tnt 0 scoreboard players add @s MineSweeper 1
       execute @s ~ ~ ~ detect ~ ~-2 ~ minecraft:tnt 0 scoreboard players set @s MineSweeper 9
    
    #Sets down the appropiate block
       execute @s[score_MineSweeper_min=1,score_MineSweeper=1] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:wool 3
       execute @s[score_MineSweeper_min=2,score_MineSweeper=2] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:wool 5
       execute @s[score_MineSweeper_min=3,score_MineSweeper=3] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:wool 14
       execute @s[score_MineSweeper_min=4,score_MineSweeper=4] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:wool 11
       execute @s[score_MineSweeper_min=5,score_MineSweeper=5] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:brick_block 0
       execute @s[score_MineSweeper_min=6,score_MineSweeper=6] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:wool 9
       execute @s[score_MineSweeper_min=7,score_MineSweeper=7] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:stained_hardened_clay 14
       execute @s[score_MineSweeper_min=8,score_MineSweeper=8] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:netherrack 0
       execute @s[score_MineSweeper_min=9] ~ ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 setblock ~ ~ ~ minecraft:tnt 0
    
    #Gives the area_effect_cloud appropiate tags to ensure that it will always be one area_effect_cloud per block
       entitydata @s {"Tags":["placed","n","s","e","w","ne","nw","se","sw"]}
       execute @e[type=minecraft:area_effect_cloud,tag=n] ~ ~ ~1 scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=n,dx=0,dy=0,dz=0,c=1] remove n
       execute @e[type=minecraft:area_effect_cloud,tag=s] ~ ~ ~-1 scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=s,dx=0,dy=0,dz=0,c=1] remove s
       execute @e[type=minecraft:area_effect_cloud,tag=e] ~-1 ~ ~ scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=e,dx=0,dy=0,dz=0,c=1] remove e
       execute @e[type=minecraft:area_effect_cloud,tag=w] ~1 ~ ~ scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=w,dx=0,dy=0,dz=0,c=1] remove w
       execute @e[type=minecraft:area_effect_cloud,tag=ne] ~-1 ~ ~1 scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=ne,dx=0,dy=0,dz=0,c=1] remove ne
       execute @e[type=minecraft:area_effect_cloud,tag=nw] ~1 ~ ~1 scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=nw,dx=0,dy=0,dz=0,c=1] remove nw
       execute @e[type=minecraft:area_effect_cloud,tag=se] ~-1 ~ ~-1 scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=se,dx=0,dy=0,dz=0,c=1] remove se
       execute @e[type=minecraft:area_effect_cloud,tag=sw] ~1 ~ ~-1 scoreboard players tag @e[type=minecraft:area_effect_cloud,tag=sw,dx=0,dy=0,dz=0,c=1] remove sw
    
    #If score is <= 0, this opens the area up
       execute @s[score_MineSweeper=0] ~ ~-1 ~ detect ~ ~ ~ lapis_block 0 setblock ~ ~ ~ minecraft:stone 6
       execute @s[score_MineSweeper=0,tag=n] ~ ~-1 ~-1 detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=s] ~ ~-1 ~1 detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=e] ~1 ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=w] ~-1 ~-1 ~ detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=ne] ~1 ~-1 ~-1 detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=nw] ~-1 ~-1 ~-1 detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=se] ~1 ~-1 ~1 detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
       execute @s[score_MineSweeper=0,tag=sw] ~-1 ~-1 ~1 detect ~ ~ ~ minecraft:lapis_block 0 summon minecraft:area_effect_cloud ~ ~1 ~ {"Duration":2147483647,"Tags":["placed"]}
    
    #Kills the necessary area_effect_clouds
       execute @e[type=area_effect_cloud,tag=placed] ~ ~ ~ detect ~ ~-1 ~ stone 6 kill @s
       kill @s
    
    #Runs this function on another area_effect_cloud if #bpt >= 1 and if the area_effect_cloud exists
       scoreboard players operation @e[type=minecraft:area_effect_cloud,tag=placeholder] MineSweeper = #bpt MineSweeper
       execute @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper_min=1,c=1] ~ ~ ~ execute @r[type=minecraft:area_effect_cloud,tag=placed] ~ ~ ~ function minesweeper:game
    The following file should be named "setupfield.mcfunction".
    Code:
    #Spawns a minefield
       execute @s[tag=smallfield] ~ ~ ~ fill ~ ~-1 ~ ~7 ~-1 ~7 minecraft:lapis_block
       execute @s[tag=smallfield] ~ ~ ~ fill ~ ~-2 ~ ~7 ~-2 ~7 minecraft:air
       execute @s[tag=mediumfield] ~ ~ ~ fill ~ ~-1 ~ ~15 ~-1 ~15 minecraft:lapis_block
       execute @s[tag=mediumfield] ~ ~ ~ fill ~ ~-2 ~ ~15 ~-2 ~15 minecraft:air
       execute @s[tag=largefield] ~ ~ ~ fill ~ ~-1 ~ ~31 ~-1 ~31 minecraft:lapis_block
       execute @s[tag=largefield] ~ ~ ~ fill ~ ~-2 ~ ~31 ~-2 ~31 minecraft:air
    
    #Sets x & z scores depending on field size
       execute @s[tag=smallfield] ~ ~ ~ scoreboard players set #x MineSweeper 8
       execute @s[tag=mediumfield] ~ ~ ~ scoreboard players set #x MineSweeper 16
       execute @s[tag=largefield] ~ ~ ~ scoreboard players set #x MineSweeper 32
       scoreboard players operation #z MineSweeper = #x MineSweeper
    
    #Runs the following function
       function minesweeper:calcfield
    
    #Kills any area_effect_cloud with the tag of "placemines" if "placeholder" <= 0
       execute @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper=0,c=1] ~ ~ ~ kill @e[tag=placemines]
    
    #Runs the tnt function if "placeholder" <= 0
       function minesweeper:tnt if @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper=0,c=1]
    The following file should be named "calcfield.mcfunction".
    Code:
    #Self Explanatory
       execute @s ~ ~ ~ function minesweeper:x
       execute @s ~ ~ ~ function minesweeper:z
    The following file should be named "x.mcfunction"
    Code:
    #summons an area_effect_cloud with the tag "rtnt" on top of the area_effect_cloud running function
       execute @s ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {"Duration":2147483647,"Tags":["rtnt"]}
    
    #Teleports the area_effect_cloud running this function to the proper x coordinate
       tp @s ~1 ~ ~
    
    #Removes a point from #x
       scoreboard players remove #x MineSweeper 1
       scoreboard players operation @e[type=minecraft:area_effect_cloud,tag=placeholder,c=1] MineSweeper = #x MineSweeper
    
    #Loops this function if #x >= 1
       function minesweeper:x if @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper_min=1,c=1]
    The following file should be named "z.mcfunction"
    Code:
    #Teleports the area_effect_cloud running this function to the proper coordinates
       tp @s[tag=smallfield] ~-8 ~ ~1
       tp @s[tag=mediumfield] ~-16 ~ ~1
       tp @s[tag=largefield] ~-32 ~ ~1
    
    #Removes a point from #z
       scoreboard players remove #z MineSweeper 1
       scoreboard players operation @e[type=minecraft:area_effect_cloud,tag=placeholder,c=1] MineSweeper = #z MineSweeper
    
    #Sets #x to needed score
       execute @s[tag=smallfield] ~ ~ ~ scoreboard players set #x MineSweeper 8
       execute @s[tag=mediumfield] ~ ~ ~ scoreboard players set #x MineSweeper 16
       execute @s[tag=largefield] ~ ~ ~ scoreboard players set #x MineSweeper 32
    
    #Loops back to calcfield if #z >= 1
       function minesweeper:calcfield if @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper_min=1,c=1]
    The following file should be named "tnt.mcfunction"
    Code:
    #Randomly picks where the tnt should be placed and places tnt
       execute @r[type=minecraft:area_effect_cloud,tag=rtnt] ~ ~ ~ scoreboard players tag @s[tag=!tnt] add tnt
       scoreboard players tag @e[tag=tnt] remove rtnt
       execute @e[type=minecraft:area_effect_cloud,tag=tnt] ~ ~ ~ setblock ~ ~-2 ~ tnt
       kill @e[tag=tnt]
    
    #If there are more mines, loop this function
       scoreboard players remove #mines MineSweeper 1
       scoreboard players operation @e[type=minecraft:area_effect_cloud,tag=placeholder,c=1] MineSweeper = #mines MineSweeper
       function minesweeper:tnt if @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper_min=1,c=1]
    
    #Kills unneeded entities and resets "placeholder" score for MineSweeper if "placeholder" <= 0
       execute @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper=0,c=1] ~ ~ ~ kill @e[type=minecraft:area_effect_cloud,tag=rtnt]
       scoreboard players reset @e[type=minecraft:area_effect_cloud,tag=placeholder,score_MineSweeper=0,c=1] MineSweeper
    Notes...
    #1 I know it's not exactly the same as what the OP originally posted, but it can easily be modified into exactly what he suggested. I simply made it the way I did because I actually started this project long ago but gave up on it, then I came back and reused what I had already done 5-6 days ago and upgraded it.

    #2 You can change the number of mines that spawn in with the minefield by changing #mines score inside of "main.mcfunction". I know this isn't the most convenient way to do it, but like I said, it's a proof of concept... :)

    #3 You can also change #btp which stands for "blocks per tick". If you change it to a higher number, more blocks will be placed in the same tick whereas a lower number means less blocks in the same tick. I added in this functionality so that you can control how many blocks per tick are placed, however I wouldn't set it too high or you will lag the game. This also only affects the "Detector" item and not the other three which spawn the field in.

    #4 If you want to organize the files into a nicer file structure, feel free to do so. Just don't forget to change the function commands accordingly.
    The reason I didn't do this myself was to make it easier to fit everything into this post. :p

    #5 The main file that makes this function work is "game.mcfunction". Everything else is either there to help it work correctly, or spawn something like a minefield to play on.

    #6 This proof of concept was tested in 1.12.1, it won't work in 1.13.

    #7 If there are any other notes I forgot to add, I'll edit them in later.
    Whew, that was long. My apologies if I was confusing, or even went a little overboard, just trying to help... :p
    Oh yea, before I forget, +1. Thanks for reading!!! :)

    ~SUPERI0N
    ShelLuser likes this.
  4. +1
    Minesweeper's a good game, and right now the Games server doesn't really have a whole lot
  5. deserves a bump, dontcha think?
  6. This would be really cool. Minesweeper was one of my first favorite computer games (along with the likes of pinball and solitaire). I'd love to see it implemented on the games server! It might be a lot harder to extract me from said server, but shhh.

    The one downside I can see is that minesweeper tends to be a SP game (and it's not even all that entertaining for spectators), and the /games server seems to be focused much more on MP stuff. Not sure if it's just due to the trouble of implementing a little 'side-dimension' for just one player, or if the focus is intended to be only on MP activities. Something to keep in mind.
  7. Pfft, y'all talking about minesweeper while we are missing the most vital of pc gaming.

    Jay2a and Sazukemono like this.
  8. Pinball in minecraft would be cool! :eek: