Made a ritual augment that makes the Ritual of Regeneration steal health from mobs to heal the player. Also tinkered with having the ritual give absorption hearts (at a slow rate)
This commit is contained in:
parent
0419800a86
commit
97907367a1
3 changed files with 117 additions and 3 deletions
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemBlock;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -67,6 +68,27 @@ import com.google.common.collect.Iterables;
|
|||
|
||||
public class Utils
|
||||
{
|
||||
public static float addAbsorptionToMaximum(EntityLivingBase entity, float added, int maximum, int duration)
|
||||
{
|
||||
float currentAmount = entity.getAbsorptionAmount();
|
||||
added = Math.min(maximum - currentAmount, added);
|
||||
|
||||
if (added <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (duration > 0)
|
||||
{
|
||||
int potionLevel = (int) ((currentAmount + added) / 4);
|
||||
entity.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, duration, potionLevel, true, false));
|
||||
}
|
||||
|
||||
entity.setAbsorptionAmount(currentAmount + added);
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
public static Item getItem(ResourceLocation resource)
|
||||
{
|
||||
return Item.REGISTRY.getObject(resource);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue