- 致编者:请牢记我们的域名wiki.mcbe-dev.net!
- 致编者:欢迎加入本Wiki的官方交流QQ群或Discord服务器!
- 基岩版1.19.31现已发布!(了解更多)
- Inner Core现已支持Xbox模组联机!(了解更多)
- 如果您是第一次来到本Wiki,欢迎注册一个账户
- 点击顶部的“编辑”或“编辑源代码”按钮即可编辑当前页面
- 请知悉:在不登录时也可以编辑和新建页面,但是您当前的IP地址会记录在编辑历史中
User:Miemie Method/function/loot tables/trade tables documentation
This is the loot tables/trade tables documentation for 基岩版1.16.1.
Version: v1.16.1
Getting Started[编辑]
Creating Loot Tables[编辑]
- Loot table and trade table JSONs are created in subfolders of the root behavior pack folder; loot tables in the
loot_tables
folder and trade tables in thetrading
folder. Some vanilla files belong in subfolders within those folders, such as the newer villager trades.
- Example of a loot table file named
custom_loot_table.json
atloot_tables/entities
folder:
{ "pools": [ { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:string", "weight": 1 } ] } ] }
- From this example, we can see that the loot table would drop one string.
Applying Loot Tables[编辑]
- Applying loot tables on an entity requires the
minecraft:loot
component in your entity. Refer to the Entities documentation to learn more about entity components.
"minecraft:loot": { "table": "loot_tables/entities/custom_loot_table.json" }
- Applying loot tables on a block requires the
minecraft:loot
component in your block. Refer to the Blocks documentation to learn more about block components.
"minecraft:loot": "loot_tables/blocks/custom_block_drop.json"
- Applying trade tables on an entity requires the
minecraft:trade_table
orminecraft:economy_trade_table
component in your entity.
"minecraft:economy_trade_table": { "table": "trading/economy_trades/custom_trades.json" }
Notes[编辑]
- Crash
- The game will crash if your loot table has bad syntax when spawning an entity with equipment, killing an entity, breaking a custom block outside creative, opening edited chest loot, fishing, or interacting with an entity that drops items.
- The game will crash if the trade table has bad syntax when opening the trade UI or loading the world, or will display the trades blank.
- Equipment Table
- Only a helmet, chestplate, Illager banner, leggings, elytra, and boots can be equipped in an entity's armor slots.
- An entity can't wear a carved pumpkin, mob heads, or custom armor, but can hold one in its main hand.
- Items that can be placed in player off-hand such as a shield can be held in an entity's off-hand.
- Trade Table
- "wants" key in trade tables does not currently accept items with functions, meaning that it will display the item in trade but will accept any item that matches this item, even if it's not named, enchanted, or has custom lore.
- Trade table behavior-component must be added in as a component group in "component groups" and not added directly in the "components" or the trades will all render blank even though the JSON may use the correct syntax.
- Economy Trade Table behavior-component works in both "component groups" and "components".
- Enchant
- Random enchants will not work on items that can't be enchanted in game (e.g. diamond, stone, apple), but weapons, tools, and armor can.
- Enchants with "levels" will use XP levels to enchant with a range of "min" to "max".
Conditions[编辑]
- Conditions are mainly used to allow specific loot table entries to be used.
- Conditions are optional.
- Conditions can be used in loot table functions. Check Functions section for more information.
- Loot table condition example:
"conditions": [ { "condition": "killed_by_player" } ]
entity_properties[编辑]
Returns true if the defined actor's properties were executed.
- Parameters
Name Type Default Value Description entity String "this" The entity to test. The value must be only "this". properties JSON Object {} The entity's properties; "on_fire" and "on_ground" are used for now.
has_mark_variant[编辑]
Returns true if the actor's mark variant is matched to the value.
- Parameters
Name Type Default Value Description value Integer 64 Tests for the actor's mark variant (if it has one).
killed_by_player[编辑]
Returns the condition true if the actor of the loot table is killed by the player.
killed_by_player_or_pets[编辑]
Returns the condition true if the actor of the loot table is killed by player or entities that has owner.
random_chance[编辑]
Sets a random chance of the specified value.
- Parameters
Name Type Default Value Description chance Decimal 0.0 The random chance of the value.
random_chance_with_looting[编辑]
Sets a random chance of the specified value. Looting enchantment increases the random chance multiplier.
- Parameters
Name Type Default Value Description chance Decimal 0.0 The random chance of the value. looting_multiplier Decimal 0.0 The multiplier for the chance if the target entity has the looting enchant that affects the actor.
random_difficulty_chance[编辑]
Sets a random chance of the specified value based on the level difficulty.
- Parameters
Name Type Default Value Description default_chance Decimal 0.0 The default random chance if the level difficulty is not assigned. peaceful Decimal 0.0 The default random chance if the level difficulty is in peaceful. Omitting this field will set the value to "default_chance" field. easy Decimal 0.0 The default random chance if the level difficulty is in easy. Omitting this field will set the value to "default_chance" field. normal Decimal 0.0 The default random chance if the level difficulty is in normal. Omitting this field will set the value to "default_chance" field. hard Decimal 0.0 The default random chance if the level difficulty is in hard. Omitting this field will set the value to "default_chance" field.
random_regional_difficulty_chance[编辑]
Sets a max regional difficulty random chance of the specified value.
- Parameters
Name Type Default Value Description max_chance Decimal 0.0 The maximum random chance value allowed.
Functions[编辑]
enchant_with_levels[编辑]
Increases the likelihood of the enchants being powerful. Example:
"functions": [ { "function": "enchant_with_levels", "treasure": true, "levels": { "min": 30, "max": 59 } } ]
enchant_randomly[编辑]
Will enchant the item completely random but do note "treasure": true will increase the chance of a better enchantment.
"functions": [ { "function": "enchant_randomly", "treasure": false } ]
enchant_random_gear[编辑]
Will only use enchantments that can be used on gear such as looting, silk touch, mending, etc., "chance" increases likely hood that it will be enchanted at all, example: 0.5 = 50%, 1.0 = 100%.
"functions": [ { "function": "enchant_random_gear", "chance": 0.5 } ]
specific_enchants[编辑]
You can specifically enchant gear.
- See Enchants for all possible enchantments.
- Examples
"functions": [ { "function": "specific_enchants", "enchants": [ { "id": "soul_speed", "level": [1, 3] } ] } ]
"functions": [ { "function": "specific_enchants", "enchants": [ "knockback", "fire_aspect" ] } ]
set_damage[编辑]
Will drop or give a damaged item with 0.5 = 50% damage remaining, 0.75 = 75% damage remaining.
"functions": [ { "function": "set_damage", "damage": { "min": 0.5, "max": 0.75 } } ]
set_data[编辑]
Will drop or give a block item with a data value. Example: white wool is 0, black wool is 15.
"functions": [ { "function": "set_data", "data": { "min": 0, "max": 15 } } ]
set_book_contents[编辑]
Will drop or give a written book with author's name and book title.
- Do not try passing the limit of text per page in the JSON file or the game may crash upon dropping the book or when the player tries opening the book in-game after picking it up/collecting it.
"functions": [ { "function": "set_book_contents", "author": "Example Author", "title": "Example Title", "pages": [ "Page 1", "Page 2", "Page 3", "Page 4", "Page 5", "Page 6", "Page 7", "Page 8", "Page 9", "Page 10" ] } ]
- rawtext is supported pages to translate strings and do other cool stuff, see rawtext documentation for more information.
- When using rawtext remember to use \ escape for special characters like " and \
"functions": [ { "function": "set_book_contents", "author": "Example Author", "title": "Example Title", "pages": [ "{\"rawtext\":[ {\"translate\":\"book.line.one\"}]}", "{\"rawtext\":[ {\"translate\":\"book.line.two\"}]}", "{\"rawtext\":[ {\"translate\":\"action.interact.mount\"}]}" ] } ]
fill_container[编辑]
Will drop or give a chest, dispenser, dropper, etc. with a custom loot table.
"functions": [ { "function": "fill_container", "loot_table": "loot_tables/gameplay/op_chest.json" } ]
set_count[编辑]
Will drop set items in a given range.
"functions": [ { "function": "set_count", "count": { "min": 1, "max": 3 } } ]
- When used in "gives" in villager trades, villagers will give the player 1 to 3 items upon loading the trade initially.
looting_enchant[编辑]
- For drop loot, will increase the dropped amount of items using the looting enchantment
- For equipment gear, will increase chance to drop by percentage of items using the looting enchantment.
"functions": [ { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ]
furnace_smelt[编辑]
Will drop a smelted item's result. Example: beef => cooked beef, iron ore => iron ingot. This example also shows how to access entity properties such as 'on_fire', 'on_ground'.
- Refer to Conditions for loot table conditions.
"functions": [ { "function": "furnace_smelt", "conditions": [ { "condition": "entity_properties", "entity": "this", "properties": { "on_fire": true } } ] } ]
minecraft:set_data_from_color_index[编辑]
Will drop a sheep's color wool based on the "minecraft:color" behavior component For example, "minecraft:color":0 will drop white wool.
"functions": [ { "function": "minecraft:set_data_from_color_index" } ]
set_banner_details[编辑]
Will drop an illager banner item ("type": 1). Types 0 and 2+ are unused.
"functions": [ { "function": "set_banner_details", "type": 1 } ]
exploration_map[编辑]
Will drop a map that has an X marking a location.
- Value is /locate command name, such as "monument", "mansion", "village", "stronghold", "temple", "ruins", "shipwreck", "pillageroutpost", "buriedtreasure", "mineshaft", "endcity", "fortress", "ruinedportal", "bastionremnant". These only work in the correct dimension, with ruined portals being locatable in both the overworld and nether.
"functions": [ { "function": "exploration_map", "destination": "monument" } ]
enchant_book_for_trading[编辑]
Will set enchantments randomly using the players' current enchantment seed in the player.dat, or local player to choose the enchantment when initially loading the trade on the entity.
- Can only be used on trades; this will not work on chest loot, entity drops, entity equipment, fishing loot, or block drop loot.
- "base_cost" is the min number used when generating a range for the enchantment.
- "base_random_cost" is the max number used when generating a range for the enchantment.
- "per_level_random_cost" is the max cost number used when generating a range and is the cost of XP needed to attach the enchantment to an item using an anvil.
- "per_level_cost" is the min cost number used when generating a range and is the cost of XP needed to attach the enchantment to an item using an anvil.
"functions": [ { "function": "enchant_book_for_trading", "base_cost": 2, "base_random_cost": 5, "per_level_random_cost": 10, "per_level_cost": 3 } ]
random_block_state[编辑]
Will choose a random block state value using the "block_state": "value"-specified, example, "coral_color", "flower_type", "sapling_type".
- Uses the internal block state names. Check bedrock edition's block state names for the key.
- This does not set the damage or data values on the block but instead sets the block state in NBT on the item when dropped.
"functions": [ { "function": "random_block_state", "block_state": "flower_type", "values": { "min": 0, "max": 10 } } ]
random_aux_value[编辑]
Will drop or give a non-block item with a data value. Example: effects of suspicious stew or tipped arrow.
"functions": [ { "function": "random_aux_value", "values": { "min": 0, "max": 9 } } ]
set_lore[编辑]
Will drop or give an item with custom lore on it. The recommended amount of characters per line is 37, including spaces. Going past this may cause characters to display offscreen on lower resolutions, consoles, or mobile devices.
"functions": [ { "function": "set_lore" "lore": [ "Line 1" "Line 2" "Line 3" ] } ]
set_name[编辑]
Will drop or give an item with a custom name.
"functions": [ { "function": "set_name" "name": "Custom Name Here!" } ]
set_actor_id[编辑]
Will set a spawn_egg item to an entity identifier. If "id" is omitted as a parameter, then it will drop its own entity identifier.
"functions": [ { "function": "set_actor_id", "id": "minecraft:creeper" } ]
random_dye[编辑]
Will set leather armor with random dye.
"functions": [ { "function": "random_dye" } ]
trader_material_type[编辑]
Will set material of items based on trader type.
- Can only be used on trades.
"functions": [ { "function": "trader_material_type" } ]
Enchants[编辑]
Name Description aqua_affinity speeds up how fast you mine blocks underwater bane_of_arthropods increases attack damage against arthropods such as spiders, silverfish, etc. blast_protection decreases blast and explosion damage channeling summons a lightning bolt at an entity when the enchanted trident is thrown, note: the entity must be in the rain curse_of_binding prevent removal of armor from armor slot curse_of_vanishing item will disappear upon death, instead of dropped. depth_strider speeds up how fast you swim under the water efficiency increases how fast you can mine feather_falling decreases fall damage and teleportation damage fire_aspect sets entity that is hit to be on fire. fire_protection decreases damage caused by fire damage and lava damage flame makes arrows on fire so when they hit an entity it sets them on fire fortune increase block drops from mining blocks such as gold ore, diamond ore & redstone ore, etc. frost_walker freezes water into ice blocks so you can walk on top of the ice impaling increases attack damage against sea creatures such as squid, drowned, cod, etc. infinity allows you to shoot an infinite amount of arrows knockback increases knockback damage against all entities, (entities will fly backwards) looting increases the loot quantity dropped when the entity is killed loyalty returns the trident to the entity after throwing luck_of_the_sea increases chances of catching valuable items while fishing lure increases the chance rate of fish biting your hook from your fishing rod mending uses the players XP to mend their tools, weapons and armor multishot allows the entity to shoots 3 arrows at once but only uses 1 arrow from the entities inventory piercing arrow can pierce through multiple entities while flying projectile_protection reduces projectile damage from arrows, fireballs, tridents, etc. protection normal protection against attacks, fire, lava, and falling punch increases knockback damage against all entities with arrows, (entities will fly backwards) quick_charge decreases the amount of time it takes to reload with a crossbow. respiration increases underwater breathing & helps you see underwater better use on helmets, riptide pushes the player forward when enchanted trident is thrown while in water or when you are in the rain. sharpness increases attack damage on a sword or axe. silk_touch mines the blocks that can't be mined under normal means, e.g. Grass Blocks, Pathway Blocks, Ice. smite increases attack damage against undead entities like zombies, skeletons, etc. soul_speed Increases the speed of the player while walking on Soul Sand and Soul Soil. power Increases all the damage dealt by a bow when applied. thorns causes damage to the attacking entities. unbreaking chance of not reducing durability when using an item.