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!
This commit is contained in:
Electroblob77
2019-08-18 00:04:18 +01:00
parent 2680d02304
commit f37812be3e
1564 changed files with 47652 additions and 12984 deletions
@@ -1,40 +1,47 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
public class Flight extends Spell {
public static final String SPEED = "speed";
public static final String ACCELERATION = "acceleration";
private static final double Y_NUDGE_ACCELERATION = 0.075;
public Flight(){
super("flight", Tier.MASTER, Element.EARTH, SpellType.UTILITY, 10, 0, EnumAction.NONE, true);
super("flight", EnumAction.NONE, true);
addProperties(SPEED, ACCELERATION);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!caster.isInWater() && !caster.isElytraFlying()){
if(!caster.isInWater() && !caster.isInLava() && !caster.isElytraFlying()){
float speed = getProperty(SPEED).floatValue() * modifiers.get(SpellModifiers.POTENCY);
float acceleration = getProperty(ACCELERATION).floatValue() * modifiers.get(SpellModifiers.POTENCY);
// The division thingy checks if the look direction is the opposite way to the velocity. If this is the
// case then the velocity should be added regardless of the player's current speed.
if((Math.abs(caster.motionX) < 0.6 || caster.motionX / caster.getLookVec().x < 0)
&& (Math.abs(caster.motionZ) < 0.6 || caster.motionZ / caster.getLookVec().z < 0)){
caster.addVelocity(caster.getLookVec().x / 20, 0, caster.getLookVec().z / 20);
if((Math.abs(caster.motionX) < speed || caster.motionX / caster.getLookVec().x < 0)
&& (Math.abs(caster.motionZ) < speed || caster.motionZ / caster.getLookVec().z < 0)){
caster.addVelocity(caster.getLookVec().x * acceleration, 0, caster.getLookVec().z * acceleration);
}
// y velocity is handled separately to stop the player from falling from the sky when they reach maximum
// horizontal speed.
if(Math.abs(caster.motionY) < 0.6 || caster.motionY / caster.getLookVec().y < 0){
caster.motionY += caster.getLookVec().y / 20 + 0.075;
if(Math.abs(caster.motionY) < speed || caster.motionY / caster.getLookVec().y < 0){
caster.motionY += caster.getLookVec().y * acceleration + Y_NUDGE_ACCELERATION;
}
caster.fallDistance = 0.0f;
if(!Wizardry.settings.replaceVanillaFallDamage) caster.fallDistance = 0.0f;
}
if(world.isRemote){
@@ -45,12 +52,10 @@ public class Flight extends Spell {
x = caster.posX - 1 + world.rand.nextDouble() * 2;
y = caster.getEntityBoundingBox().minY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
z = caster.posZ - 1 + world.rand.nextDouble() * 2;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(1, 1, 1).spawn(world);
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, -0.1, 0).time(15).clr(1f, 1f, 1f).spawn(world);
}
if(ticksInUse % 24 == 0){
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_FLAP, 0.5F, 1.0f);
}
if(ticksInUse % 24 == 0) playSound(world, caster, ticksInUse, -1, modifiers);
return true;
}