All users will need to merge their Minecraft Forum account with a new or existing Twitch account starting October 23rd. You can merge your accounts by clicking here. Have questions? Learn more here.
Dismiss
  • 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 or register a new account.