• 1

    posted a message on How to make a mob summon when a player is close enough to a command block?

    First off, the selector @a[distance=100] is checking for a player that is precisely 100 blocks away from the command block rather than 100 blocks or less. To avoid any issues, use @a[distance=..100], which will check for a player within 100 blocks. Secondly, the summon command doesn't work with selectors; the /gamemode command uses selectors in order to determine which players to change the gamemode of. In order to only run a command when a specific entity is found, use the execute command:
    /execute if entity @a[distance=..2] run summon minecraft:elder_guardian ~ ~1 ~

    When put into a repeating command block that is powered with redstone, this command will summon elder_guardians constantly when a player is within 2 blocks of the command block.

    You could also split up the commands and do this:

    Where the command block on the left is set to repeating and has the command

    /execute if entity @a[distance=..5]
    And the command block on the right has the command
    /summon minecraft:elder_guardian ~ ~1 ~

    This will summon an Elder Guardian only once when the player gets close enough and again after they leave and come back.

    Play around with the settings a bit more if you want too! You can actually change the location from where the distance is checked too with x, y, and z: @a[x=x,y=y,z=z,distance=..d] (replace x, y, and z with numbers).
    This means you could actually place the command blocks below the ground and have them check if a player is right above them.

    Happy to help out a fellow Tree Puncher!

    Posted in: Redstone Discussion and Mechanisms
  • 1

    posted a message on Looking for a better in-game book editor

    I know it's an old post, but I found a replacement after researching for a few hours. I've wanted one of these two, and I found one for 1.7+. For 1.6.X you can use BookZ. But for anything above, you can use Ghostwriter. It is updated all the way to 1.12.2 as of today. I have no idea why Google had trouble finding it when I looked up "minecraft 1.12.2 book editor". For future viewers, you are welcome.

    Posted in: Requests / Ideas For Mods
  • 1

    posted a message on [SOLVED] Functions - Prevent specific item from being put in chests

    You should be okay to test for and setblock with no problem, provided you use the correct syntax and different scoreboard objectives. I find it interesting though, you never actually change the value of the "chesthasitem" objective (Unless you are using something behind the scenes, like a stats command); obviously it would never delete the block because there is no player that has a score of "chesthasitem" that is at least 1. a series of /testforblock commands to determine if the block near a player has an item in it. Keep in mind, if you want to test for the item in any inventory, you are going to have to test not only chests, but every other block that has an inventory as well. I can work on a function that could do this for you, but I suggest other simpler solutions if possible. Could I have a bit more information about what you are doing this on? Here are some questions that may help me determine another option if possible.

    1. Are you doing this on an adventure map? If so, can your players place down any blocks that have inventory?

    2. Is this a survival world?

    3. Do you just want the function?

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on [SOLVED] Functions - Prevent specific item from being put in chests

    I can't think of a simple solution other than by using plugins. To my knowledge, there is no way of testing for a specific item is in a chest other than by testing billions of billions of possibilities, and it is impossible to do this easily (correct me if I'm wrong). Also, note that you can't go too complex, functions lag if you run too many commands; I deal with it myself. You may be able to do a workaround for what you are trying to do though; could you tell me why you need to prevent the item from going into chests? The more background you give the better (just don't make it too long)


    Edit:

    I didn't realize that testing inventories of chests is similar to testing players inventories. This could be possible, see my response below

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Help with loot tables

    For future reference, you can read all about loot tables here.


    Minecraft holds all of their default loot tables (in JSON format) inside the version jar file (1.10 jar, 1.12.2 jar, etc.) under "/assets/minecraft/loot_tables", and the default shulker loot table (with shells) looks like this:


    {
      "pools": [
        {
          "conditions": [
            {
              "condition": "random_chance_with_looting",
              "chance": 0.5,
              "looting_multiplier": 0.0625
            }
          ],
          "rolls": 1,
          "entries": [
            {
              "type": "item",
              "name": "minecraft:shulker_shell"
            }
          ]
        }
      ]
    }


    You can add extra "pools" to this table to make it drop more items. In your case we want to add a monster spawner with special nbt (you can do this with or without looting by changing the condition).


    {
      "pools": [
        {
          "conditions": [
            {
              "condition": "random_chance_with_looting",
              "chance": 0.5,
              "looting_multiplier": 0.0625
            }
          ],
          "rolls": 1,
          "entries": [
            {
              "type": "item",
              "name": "minecraft:shulker_shell"
            }
          ]
        },
        {
          "conditions": [
            {
              "condition": "random_chance",
              "chance": 0.005
            }
          ],
          "rolls": 1,
          "entries": [
            {
              "type": "item",
              "name": "minecraft:mob_spawner",
              "functions": [
                {
                  "function": "set_nbt",
                  "tag": "{}"
                }
              ]
            }
          ]
        }
      ]
    }


    The tag you specifically want to use is (everything inside the quotes, including the backslashes):

    "{display:{Name:\"\u00A7rShulker Spawner\"},BlockEntityTag:{Delay:99s,SpawnCount:1s,MaxSpawnDelay:400s,SpawnRange:4s,MinSpawnDelay:200s,SpawnData:{id:\"shulker\",Color:10b},SpawnPotentials:[{Entity:{id:\"shulker\",Color:10},Weight:1}]}}"


    This will be a purple colored shulker spawner with the name "Shulker Spawner" not in italics. It also has a few other qualities unlike other spawners; for example, it only spawns one shulker at a time between 10-20 seconds. You can look up all of the different tags of spawners here and change what you like, just make sure that "SpawnData" and "SpawnPotentials" are both in the tag somewhere.


    Once you have your entire code written the way you like inside the json file, save it as "shulker.json" anywhere you like (just not inside the jar file we talked about earlier). You need to then take the loot table and drop it into

    "<YOUR_WORLD_FOLDER>/data/loot_tables/minecraft/entities" (the folders "minecraft" and "entities" don't normally exist, so you may have to create them). You can do this while your server is running and type "/reload" when you're done, or you can restart your server when you make the changes.

    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please .