LKEnchantment - Lemonszz/LKLib GitHub Wiki

The LKEnchantment class can be found within party.lemons.lklib.enchantment.

This class is a child of the vanilla Enchantment class that allows for some extra functionality. To use this for your enchantments, simply have your enchantment's class extend the LKEnchantment class.

Attributes

LKEnchantments have the ability to apply entity attributes to a entity that's holding or wearing an item with the enchantment.

Attributes will be automatically added and removed from the entity. To register an attribute for your enchantment, override the initAttributes method:

	@Override
	public void initAttributes()
	{
		addAttributeModifier(EntityAttributes.GENERIC_MAX_HEALTH, UUID.randomUUID().toString(), -2, EntityAttributeModifier.Operation.ADDITION);
	}

This will remove 2 max health from an entity per enchantment level.
If you wish to change the formula to calculate the enchantment level effectiveness of the attribute, override the adjustModifierAmount method.

onTick

LKEnchantments are ticked while a entity is holding or wearing an item with the enchantment applied.
Override the onTick method to implement your logic.

	@Override
	public void onTick(LivingEntity entity, ItemStack stack, int level)
	{
		if(entity.isTouchingWater())
		{
			entity.damage(DamageSource.CACTUS, 10); //prickly water
		}
	}