Skip to content

Tutorial: Creating a Loot Table

robotnikthingy edited this page Mar 23, 2018 · 7 revisions

Worldschematics 2 allows you to create loot tables which can be used to spawn loot and other items in schematics with chests in them. The loot can be randomized using a weighted chance system, and use items from the plugins MythicMobs and CrackShot.

Make the Loot Table File

First we need to create a loot table file. Loot Table files should be placed in the LootTables folder in the WorldSchematics2 plugin folder. For this example, we will name this loot table file MyLootTable.yml

Here is a template you can use with your loot table

Loot:
#loot will go here
    
Options:
  #MaxItems - the maximum amount of items which will be placed in the chest
  #MinItems - the minimum amount of items which will be placed in the chest
  MaxItems: 10
  MinItems: 6

Adding a simple Loot Item

Now we need to add our loot. In the loot table file, we will go and add a diamond sword

Loot:
  Item1: #you can name this part whatever you want
    Type: item
    Material: DIAMOND_SWORD
    Chance: 10
    MinAmount: 1
    MaxAmount: 3
Options:
  #MaxItems - the maximum amount of items which will be placed in the chest
  #MinItems - the minimum amount of items which will be placed in the chest
  MaxItems: 10
  MinItems: 6

So lets explain what these options we added do

Item1: - this is just used by the plugin to tell it this is a stack of items we are adding. You can name it whatever you want, just make sure its not named the same as another item. For this example though, we will simply call it Item1

Type: - This tells the plugin what type of item this is. Since this an item from regular Minecraft, we will put item here. Other options include crackshotitem and mythicmobcitem, which tells the plugin this item is from crackshot of mythicmobs. More on this later.

Material: - This determined what the item is. We used DIAMOND_SWORD since we want to use a diamond sword. This will accept any item listed in spigots list of Material items here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html Note: If you want to use Item ID's instead, you can replace Material: with ID: and put an item ID in instead.

Chance: - This determines the chance of this item appearing. This uses a weighted chance system, and since there are no other items in the config right now that means a diamond sword will be be included in the chest 100% of the time.

MinAmount: and MaxAmount: This determines how many of this item to include in the item stack. It will be anywhere between MinAmount and MaxAmount

**MaxItems: and MinItems: This determines the Maximum and Minimum amount of items which will appear in this chest. The amount that will appear in the chest will be anywhere between MaxItems and MinItems

Now lets say we wanted the Diamond sword to be rare, and want there to be a bunch of common items more likely to appear instead. We will change the Loot Table to have some common items such as Cobblestone, Iron Ingots, Gold Ingots, Apples, and Melon Slices.

Loot:
  Item1:
    Type: item
    Material: DIAMOND_SWORD
    Chance: 5
    MinAmount: 1
    MaxAmount: 1
  Item2:
    Type: item
    Material: COBBLESTONE
    Chance: 80
    MinAmount: 10
    MaxAmount: 30
  Item3:
    Type: item
    Material: MELON
    Chance: 80
    MinAmount: 5
    MaxAmount: 5
  Item4:
    Type: item
    Material: APPLE
    Chance: 40
    MinAmount: 1
    MaxAmount: 5
  Item5:
    Type: item
    Material: IRON_INGOT
    Chance: 30
    MinAmount: 1
    MaxAmount: 5
  Item6:
    Type: item
    Material: GOLD_INGOT
    Chance: 30
    MinAmount: 1
    MaxAmount: 3
Options:
  #MaxItems - the maximum amount of items which will be placed in the chest
  #MinItems - the minimum amount of items which will be placed in the chest
  MaxItems: 20
  MinItems: 10

Adding a custom item to a Loot Table

Loot tables can have items with custom Lore, data values, names, and other options

Here is an example of a diamond sword with custom lore, name, and enchantments

  AwesomeOverpoweredSword:
    Type: item
    Material: DIAMOND_SWORD
    Display: "Overpowered Sword"
    Lore:
    -"KILLS EVERYTHING"
    -"AHHHHHH"
    #list of enchantments applied to the item and their level
    Enchantments:
    - DAMAGE_ALL:10
    - DURABILITY:5
    - KNOCKBACK:5
    HideAttributes: true
    Unbreakable: true
    Chance: 1
    MinAmount: 1
    MaxAmount: 1

Adding a weapon from CrackShot to a LootTable

Loot tables can have weapons from crackshot in them as well if you have the CrackShot plugin installed on your server

Here is an example item entry for a grenade from CrackShot

  GrenadeItem:
    Type: crackshotitem
    Name: Grenade
    Chance: 5
    MinAmount: 1
    MaxAmount: 3

Adding an item from MythicMobs to a LootTable

Loot tables can have items from MythicMobs in them if you have MythicMobs installed on your server

Here is an example item entry for the Skeleton Kings sword from MythicMobs

  #has a chance of putting 1 Skeleton King sword from MythicMobs in the chest
  Mythicmobsitem:
    Type: mythicmobsitem
    Name: SkeletonKingSword
    Chance: 20
    MinAmount: 1
    MaxAmount: 1

Full list of options for items

Here is a full list of options which can be added to an item.

  Exampleitem:
    Type: <ITEM/CRACKSHOTITEM/MYTHICMOBSITEM>
    Material: <Item Material>
    ID: <Item ID number> #Use if you want to use item ID number instead of material
    Data: <Item Data> #Specifies the item data, or damage value if its an item that can be damaged.
    Display: <Custom Item Name>
    Lore:
    - <Lore Line 1>
    - <Lore Line 2>
    - <Lore Line 3>
    Enchantments:
    - <Enchantment:Enchantment level>
    - <Enchantment:Enchantment level>
    HideAttributes: <true/false>
    Unbreakable: <true/false>
    #used for player heads
    PlayerTexture: <player name>
    Chance: <chance>
    MinAmount: <amount>
    MaxAmount: <amount>