BloodMagic/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java

57 lines
1.7 KiB
Java
Raw Normal View History

2015-12-27 19:38:12 -05:00
package WayofTime.bloodmagic.potion;
import WayofTime.bloodmagic.BloodMagic;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
2015-12-27 19:38:12 -05:00
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2015-12-27 19:38:12 -05:00
public class PotionBloodMagic extends Effect {
public static ResourceLocation texture = new ResourceLocation(BloodMagic.MODID, "textures/misc/potions.png");
2017-08-15 21:30:48 -07:00
public PotionBloodMagic(String name, boolean badEffect, int potionColor, int iconIndexX, int iconIndexY) {
2016-03-18 14:54:31 -04:00
super(badEffect, potionColor);
2015-12-27 19:38:12 -05:00
this.setPotionName(name);
this.setIconIndex(iconIndexX, iconIndexY);
}
@Override
public boolean shouldRenderInvText(EffectInstance effect) {
return true;
}
public EffectInstance apply(LivingEntity entity, int duration) {
return apply(entity, duration, 0);
}
public EffectInstance apply(LivingEntity entity, int duration, int level) {
EffectInstance effect = new EffectInstance(this, duration, level, false, false);
entity.addPotionEffect(effect);
return effect;
}
public int getLevel(LivingEntity entity) {
EffectInstance effect = entity.getActivePotionEffect(this);
2017-08-15 21:30:48 -07:00
if (effect != null) {
return effect.getAmplifier();
}
return 0;
}
@Override
public boolean shouldRender(EffectInstance effect) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
2017-08-15 21:30:48 -07:00
public int getStatusIconIndex() {
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
return super.getStatusIconIndex();
}
2015-12-27 19:38:12 -05:00
}