BloodMagic/src/main/java/WayofTime/bloodmagic/api/util/helper/PurificationHelper.java
Nicholas Ignoffo 08258fd6ef Run formatter
2017-08-15 21:30:56 -07:00

33 lines
No EOL
1 KiB
Java

package WayofTime.bloodmagic.api.util.helper;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.nbt.NBTTagCompound;
public class PurificationHelper {
public static double getCurrentPurity(EntityAnimal animal) {
NBTTagCompound data = animal.getEntityData();
if (data.hasKey(Constants.NBT.CURRENT_PURITY)) {
return data.getDouble(Constants.NBT.CURRENT_PURITY);
}
return 0;
}
public static void setCurrentPurity(EntityAnimal animal, double amount) {
NBTTagCompound data = animal.getEntityData();
data.setDouble(Constants.NBT.CURRENT_PURITY, amount);
}
public static double addPurity(EntityAnimal animal, double added, double max) {
double currentPurity = getCurrentPurity(animal);
double newAmount = Math.min(max, currentPurity + added);
if (newAmount < max) {
setCurrentPurity(animal, newAmount);
return newAmount - currentPurity;
}
return 0;
}
}