use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.
the class BrewUtils method createBrew.
public static ItemStack createBrew(Item item, BrewEffect... effects) {
ItemStack stack = new ItemStack(item);
NBTTagList list = addBrewData(stack);
for (BrewEffect effect : effects) {
NBTTagCompound tag = new NBTTagCompound();
IBrew brew = effect.getBrew();
tag.setInteger(BREW_ID, BrewRegistry.getBrewId(brew));
tag.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
tag.setInteger(BREW_DURATION, effect.getDuration());
list.appendTag(tag);
}
return stack;
}
use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.
the class BrewUtils method serialize.
public static NBTTagCompound serialize(Collection<Object> collection) {
List<BrewEffect> brewEffects = new ArrayList<>();
List<PotionEffect> potionEffects = new ArrayList<>();
for (Object brew : collection) {
if (brew instanceof BrewEffect) {
brewEffects.add((BrewEffect) brew);
} else if (brew instanceof PotionEffect) {
potionEffects.add((PotionEffect) brew);
}
}
NBTTagCompound compound = new NBTTagCompound();
appendPotions(compound, mixPotions(potionEffects));
appendBrews(compound, mixBrews(brewEffects));
return compound;
}
use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.
the class ModBrews method init.
public static void init() {
SHELL_ARMOR = BrewRegistry.registerBrew(new ShellArmorBrew());
BrewRegistry.addDefault(new BrewEffect(SHELL_ARMOR, 2500, 0));
INNER_FIRE = BrewRegistry.registerBrew(new InnerFireBrew());
BrewRegistry.addDefault(new BrewEffect(INNER_FIRE, 1500, 0));
SPIDER_NIGHTMARE = BrewRegistry.registerBrew(new SpiderNightmareBrew());
BrewRegistry.addDefault(new BrewEffect(SPIDER_NIGHTMARE, 500, 0));
EXTINGUISH = BrewRegistry.registerBrew(new ExtinguishBrew());
BrewRegistry.addDefault(new BrewEffect(EXTINGUISH, 500, 0));
WARWATER = BrewRegistry.registerBrew(new WarWaterBrew());
BrewRegistry.addDefault(new BrewEffect(WARWATER, 1500, 0));
FROSTBITE = BrewRegistry.registerBrew(new FrostbiteBrew());
BrewRegistry.addDefault(new BrewEffect(FROSTBITE, 500, 0));
}
use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.
the class BrewSimpleModifier method apply.
@Override
public boolean apply(List<Object> brews, Object current) {
if (current instanceof PotionEffect) {
PotionEffect effect = (PotionEffect) current;
if (effect.getDuration() < 9600) {
int hue = MathHelper.clamp(effect.getDuration() + duration, 0, 9600);
effect.combine(new PotionEffect(effect.getPotion(), hue, effect.getAmplifier()));
}
if (effect.getAmplifier() < 3) {
int hue = MathHelper.clamp(effect.getAmplifier() + amplifier, 0, 3);
effect.combine(new PotionEffect(effect.getPotion(), effect.getDuration(), hue));
}
} else if (current instanceof BrewEffect) {
BrewEffect effect = (BrewEffect) current;
if (effect.getDuration() < 9600) {
int hue = MathHelper.clamp(effect.getDuration() + duration, 0, 9600);
effect.setDuration(hue);
}
if (effect.getAmplifier() < 3) {
int hue = MathHelper.clamp(effect.getAmplifier() + amplifier, 0, 3);
effect.setAmplifier(hue);
}
}
return true;
}
use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.
the class BrewStorageHandler method addEntityBrewEffect.
/**
* Add a BrewEffect to the entity.
*
* @param entity The entity
* @param effect The effect
*/
public static void addEntityBrewEffect(EntityLivingBase entity, BrewEffect effect) {
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
if (optional.isPresent()) {
Map<IBrew, BrewEffect> effectMap = optional.get().getBrews();
BrewEffect out = effectMap.get(effect.getBrew());
if (out == null || effect.getDuration() > out.getDuration()) {
effectMap.put(effect.getBrew(), effect);
}
optional.get().setBrews(effectMap);
}
}
Aggregations