-
Notifications
You must be signed in to change notification settings - Fork 0
Locking Enchantments
You can call the Enchantment package by mods.plustweaks.Enchantment.
mods.plustweaks.Enchantment.lockEnchantment(IEnchantmentDefinition enchant, Map<IBlockState, Integer> blocks);
You can use this method to lock certain enchantments, those enchantments will not appear in a enchantment table if the 7 * 2 * 7 (x * y * z) area (counting up) centered around the table does not contain the blocks specified.
Example:
import crafttweaker.block.IBlockState;
mods.plustweaks.Enchantment.lockEnchantment(<enchantment:minecraft:protection>, {<blockstate:minecraft:stone> : 5, <blockstate:minecraft:grass> : 3} as int[IBlockState]);
Note that the code block above uses a IEnchantmentDefinition object and a Associative Array. For more information on how to get those varibles, check the crafttweaker official wiki page.
This will make it that if the 7 * 2 * 7 area does not contain at least 5 stones and 3 grass blocks, the player won't be able to get protection enchantment (any level).
mods.plustweaks.Enchantment.lockEnchantment(IEnchantment enchantment, Map<IBlockState, Integer> blocks);
This is pretty much the same as the one above, with the only difference being it requires an IEnchantment object instead of a IEnchantmentDefinition, which makes locking level-specific enchant possible.
Example:
import crafttweaker.block.IBlockState;
mods.plustweaks.Enchantment.lockEnchantment(<enchantment:minecraft:protection>.makeEnchantment(1), {<blockstate:minecraft:stone> : 5, <blockstate:minecraft:grass> : 3} as int[IBlockState]);
Note that you can get an IEnchantment object by calling makeEnchantment on an IEnchantmentDefinition object.
This will lock Protection I only (instead of locking every level of protection).