use of net.minecraft.potion.Potion in project Nutrition by WesCook.
the class EffectsList method parseJson.
// Parse JSON data into more useful objects
public static void parseJson() {
for (JsonEffect effectRaw : jsonEffects) {
// Skip if effect is not enabled, or if field omitted (null)
if (effectRaw.enabled != null && !effectRaw.enabled)
continue;
// Get potion from config
Potion potion = Potion.getPotionFromResourceLocation(effectRaw.potion);
if (potion == null) {
Log.error("Potion '" + effectRaw.potion + "' is not valid (" + effectRaw.name + ").");
continue;
}
// Copying and cleaning data
Effect effect = new Effect();
effect.name = effectRaw.name;
effect.potion = potion;
effect.minimum = effectRaw.minimum;
effect.maximum = effectRaw.maximum;
effect.detect = effectRaw.detect;
// Amplifier defaults to 0 if undefined
effect.amplifier = (effectRaw.amplifier != null) ? effectRaw.amplifier : 0;
// Default the cumulative modifier to 1 if not defined
effect.cumulativeModifier = (effectRaw.cumulative_modifier != null) ? effectRaw.cumulative_modifier : 1;
// If nutrients are unspecified in file, this defaults to include every nutrient
if (effectRaw.nutrients.size() == 0) {
effect.nutrients.addAll(NutrientList.get());
} else {
// Field has been set, so fetch nutrients by name
for (String nutrientName : effectRaw.nutrients) {
Nutrient nutrient = NutrientList.getByName(nutrientName);
if (nutrient != null)
// Nutrient checks out, add to list
effect.nutrients.add(nutrient);
else
Log.error("Nutrient " + nutrientName + " not found (" + effectRaw.name + ").");
}
}
// Register effect
effects.add(effect);
}
}
use of net.minecraft.potion.Potion in project BloodMagic by WayofTime.
the class Utils method applyPotionDamageCalculations.
public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage) {
Potion resistance = MobEffects.RESISTANCE;
if (source.isDamageAbsolute()) {
return damage;
} else {
if (attackedEntity.isPotionActive(resistance) && source != DamageSource.OUT_OF_WORLD) {
int i = (attackedEntity.getActivePotionEffect(resistance).getAmplifier() + 1) * 5;
int j = 25 - i;
float f = damage * (float) j;
damage = f / 25.0F;
}
if (damage <= 0.0F) {
return 0.0F;
} else {
int k = EnchantmentHelper.getEnchantmentModifierDamage(attackedEntity.getArmorInventoryList(), source);
if (k > 20) {
k = 20;
}
if (k > 0 && k <= 20) {
int l = 25 - k;
float f1 = damage * (float) l;
damage = f1 / 25.0F;
}
return damage;
}
}
}
use of net.minecraft.potion.Potion in project takumicraft by TNTModders.
the class EntityDarkCreeper method takumiExplodeEvent.
@Override
public boolean takumiExplodeEvent(Detonate event) {
for (Entity entity : event.getAffectedEntities()) {
if (entity instanceof EntityLivingBase) {
boolean done = false;
for (int i = 0; i < 50 && !done; i++) {
done = this.teleportTo((EntityLivingBase) entity);
}
Potion potion = MobEffects.BLINDNESS;
switch(this.rand.nextInt(6)) {
case 0:
break;
case 1:
potion = MobEffects.NAUSEA;
break;
case 2:
potion = MobEffects.SLOWNESS;
break;
case 3:
potion = MobEffects.HUNGER;
break;
case 4:
potion = MobEffects.UNLUCK;
break;
case 5:
if (this.rand.nextBoolean() && this.getPowered()) {
potion = MobEffects.LEVITATION;
}
break;
}
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(entity.world, entity.posX, entity.posY, entity.posZ);
entityareaeffectcloud.setRadius(5F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration());
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
entityareaeffectcloud.addEffect(new PotionEffect(potion, potion == MobEffects.LEVITATION ? 100 : 1200, this.getPowered() ? 1 : 0));
this.world.spawnEntity(entityareaeffectcloud);
}
}
return true;
}
use of net.minecraft.potion.Potion in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderBuffs.
public void RenderBuffs(int i, int j) {
if (!AMCore.config.getShowBuffs()) {
return;
}
int barWidth = i / 8;
AMVector2 posBuffStart = getShiftedVector(AMCore.config.getPositiveBuffsPosition(), i, j);
AMVector2 negBuffStart = getShiftedVector(AMCore.config.getNegativeBuffsPosition(), i, j);
int positive_buff_x = posBuffStart.iX;
int positive_buff_y = posBuffStart.iY;
int negative_buff_x = negBuffStart.iX;
int negative_buff_y = negBuffStart.iY;
for (PotionEffect pe : getPotionEffectsByTimeRemaining()) {
this.mc.renderEngine.bindTexture(inventory);
int potionID = pe.getPotionID();
if (potionID < 0 || potionID >= Potion.potionTypes.length)
continue;
Potion potion = Potion.potionTypes[potionID];
if (potion == null)
continue;
if (potion.isBadEffect()) {
if (potion.hasStatusIcon()) {
int l = potion.getStatusIconIndex();
if (pe.getDuration() < 100) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.fastFlashAlpha);
} else if (pe.getDuration() < 200) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.slowFlashAlpha);
}
this.drawTexturedModalRect_Classic(negative_buff_x, negative_buff_y, 0 + l % 8 * 18, 198 + l / 8 * 18, 10, 10, 18, 18);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
negative_buff_x -= 12;
if (negative_buff_x <= negBuffStart.iX - 48) {
negative_buff_x = negBuffStart.iX;
negative_buff_y += 12;
}
}
} else {
this.mc.renderEngine.bindTexture(inventory);
if (potion.hasStatusIcon()) {
int l = potion.getStatusIconIndex();
if (pe.getDuration() < 100) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.fastFlashAlpha);
} else if (pe.getDuration() < 200) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.slowFlashAlpha);
}
this.drawTexturedModalRect_Classic(positive_buff_x, positive_buff_y, 0 + l % 8 * 18, 198 + l / 8 * 18, 10, 10, 18, 18);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
positive_buff_x += 12;
if (positive_buff_x >= posBuffStart.iX + 48) {
positive_buff_x = posBuffStart.iX;
positive_buff_y += 12;
}
}
}
}
}
use of net.minecraft.potion.Potion in project ArsMagica2 by Mithion.
the class BuffList method setPotionArrayLength.
private static void setPotionArrayLength(int length) throws Exception {
if (length <= Potion.potionTypes.length)
return;
Potion[] potions = new Potion[length];
for (int i = 0; i < Potion.potionTypes.length; ++i) {
potions[i] = Potion.potionTypes[i];
}
Field field = null;
Field[] fields = Potion.class.getDeclaredFields();
for (Field f : fields) {
if (f.getType().equals(Potion[].class)) {
field = f;
break;
}
}
setFinalStatic(field, potions);
}
Aggregations