External LootTables
By TheDiamondBlue1
About It
What Is It?
The External LootTables script/addon is a tool designed to help developers and creators modify vanilla mob loot tables without directly editing them. It allows you to dynamically add loot tables via script, offering extensive customization with both vanilla and custom conditions and functions.
This flexibility makes it easy to tailor loot tables to fit your needs, whether you're working with vanilla or custom entities.
How It Works
There are 4 keys files that power the system. Here's what each file does:
-
lootComponents.js:
-
Handles the loot processing logic, ensuring everything runs smoothly.
-
-
evaluateConditions.js:
-
Manages all the conditions used to determine if loot should drop.
-
-
functionProcessor.js:
-
Processes the functions applied to loot, enabling addition customisation.
-
-
customFamily.js:
-
Handles custom families. This lets you group mobs into one or more custom families for shared loot tables. You can also use vanilla families for convenience.
-
-
lootTables.js:
-
This is the heart of the addon, where you define loot tables for specific entities or families. The magic happens here
-
What's Next?
Below, you'll find detailed explanations of the available conditions and functions, including how they work and how to set them up.
Example Code
Below is an example of a mobLoot configuration with custom loot logic for a Zombie entity.
Below is an example of a familyLoot configuration with custom loot logic for the Undead entity.
Functions & Conditions
List of Functions
Set Count
The "set_count" function allows you to set the count of the items. There are two types of the Set Count function, the absolute amount under count and the random amount under countRange.
The code on the right shows you how to code both the Absolute amount and the Random amount.
*Please don't put both in together under a single entry or it won't work as intended
Set Name
The "set_name" function lets you change the name of the item that is being dropped. You can pair the Set Name function with the Set Lore function to customise the dropped item even more.
Tip: Using the special character "§" lets you customise how it looks by changing its colour. Example is "§9" is Blue, "§l" is Bold, and "§o" is Italic
*Use "§r" to reset it to non-italics
Set Lore
The "set_lore" function lets you give the item that is drop to have a Lore attached to it. You can pair the Set Name function with the Set Lore function to customise the dropped item even more.
Tip: Using the special character "§" lets you customise how it looks by changing its colour. Example is "§9" is Blue, "§l" is Bold, and "§o" is Italic
*Use "§r" to reset it to non-italics
Looting Enchant
The "looting_enchant" function lets you have the item drop more if the player is using looting.
The looting works by taking a random amount between the two values and multiplies it with the looting enchantment. Higher your enchant level, more you get from a drop.
*Change the min to a different amount if you want to 100% guarantee an extra drop
Apply Enchantment
The "apply_enchantment" function lets you have the item that drops have a specific enchantment. That means that if you want that sword that drops have Sharpness IV then you can add it. The code on the right shows how it works
*Same rules apply, only items that can be enchanted can be enchanted and highest level is its max
List of Conditions
Kill By Player
The "killed_by_player" conditions is used to see if the mob is killed by a player. If it is true, then it will continue the drop.
Kill By Player or Pets
The "killed_by_player_or_pets" conditions is used to see if the mob is killed by a player or their pets. If it is true, then it will continue the drop.
Random Chance
The "random_chance" conditions is used to give the drop a random chance to drop.
How The Chance Works
25% = 0.25
2% = 0.02
50% = 0.5
Random Chance With Looting
The "random_chance_with_looting" conditions is used to give the drop a random chance to drop if you have looting
How The Chance Works
25% = 0.25
2% = 0.02
50% = 0.5
Time Check
The "time_check" conditions is used to test what time of day it. If the time falls between the min & max, it will continue the drop
Main Time
Day = 1000
Noon = 6000
Sunset = 12000
Night = 13000
Midnight = 18000
Sunrise = 23000
Has Marked Variant
The "has_mark_variant" conditions is used to test if the entity has the marked variant.
Example: Desert and Jungle Villagers are Mark Variants
*"has_mark_variant" is different from "has_variant"
Has Variant
The "has_variant" conditions is used to test if the entity has the variant.
Example: Armour and Cleric Villagers are Variants
*"has_variant" is different from "has_mark_variant"