Files
Wizardry/src/main/java/electroblob/wizardry/spell/Satiety.java
T
Electroblob77 f37812be3e That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
2019-08-18 00:04:18 +01:00

41 lines
1.4 KiB
Java

package electroblob.wizardry.spell;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
public class Satiety extends SpellBuff {
public static final String HUNGER_POINTS = "hunger_points";
public static final String SATURATION_MODIFIER = "saturation_modifier";
public Satiety(){
super("satiety", 1, 0.7f, 0.3f);
this.soundValues(0.7f, 1.2f, 0.4f);
addProperties(HUNGER_POINTS, SATURATION_MODIFIER);
}
@Override public boolean canBeCastByNPCs(){ return false; }
@Override
protected boolean applyEffects(EntityLivingBase caster, SpellModifiers modifiers){
return true; // In this case the best solution is to remove the functionality of this method and override cast.
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.getFoodStats().needFood()){
int foodAmount = (int)(getProperty(HUNGER_POINTS).floatValue() * modifiers.get(SpellModifiers.POTENCY));
// Fixed issue #6: Changed to addStats, since setFoodLevel is client-side only
caster.getFoodStats().addStats(foodAmount, getProperty(SATURATION_MODIFIER).floatValue());
return super.cast(world, caster, hand, ticksInUse, modifiers);
}
return false;
}
}