diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index e347350b..4e345f09 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -58,8 +58,8 @@ public class EarthPonyStompAbility implements Ability { @Nullable @Override public Hit tryActivate(Pony player) { - if (!player.getMaster().isOnGround() && !player.getMaster().abilities.flying) { - thrustDownwards(player.getMaster()); + if (!player.getMaster().isOnGround() && player.getMaster().getVelocity().y * player.getPhysics().getGravitySignum() < 0 && !player.getMaster().abilities.flying) { + thrustDownwards(player); return Hit.INSTANCE; } @@ -71,22 +71,22 @@ public class EarthPonyStompAbility implements Ability { return Hit.SERIALIZER; } - private void thrustDownwards(PlayerEntity player) { - BlockPos ppos = player.getBlockPos(); - BlockPos pos = PosHelper.findSolidGroundAt(player.getEntityWorld(), ppos); + private void thrustDownwards(Pony player) { + BlockPos ppos = player.getOrigin(); + BlockPos pos = PosHelper.findSolidGroundAt(player.getWorld(), ppos, player.getPhysics().getGravitySignum()); - double downV = Math.sqrt(ppos.getSquaredDistance(pos)); - player.addVelocity(0, -downV, 0); + double downV = Math.sqrt(ppos.getSquaredDistance(pos)) * player.getPhysics().getGravitySignum(); + player.getMaster().addVelocity(0, -downV, 0); } @Override public void apply(Pony iplayer, Hit data) { PlayerEntity player = iplayer.getMaster(); - thrustDownwards(player); + thrustDownwards(iplayer); iplayer.waitForFall(() -> { - BlockPos center = PosHelper.findSolidGroundAt(player.getEntityWorld(), player.getBlockPos()); + BlockPos center = PosHelper.findSolidGroundAt(player.getEntityWorld(), player.getBlockPos(), iplayer.getPhysics().getGravitySignum()); float heavyness = 1 + EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player); @@ -101,7 +101,7 @@ public class EarthPonyStompAbility implements Ability { } inertia /= heavyness; - double liftAmount = Math.sin(Math.PI * dist / rad) * 12; + double liftAmount = Math.sin(Math.PI * dist / rad) * 12 * iplayer.getPhysics().getGravitySignum(); i.addVelocity( -(player.getX() - i.getX()) / inertia, diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java index 4691ff97..d2549a3e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java @@ -30,7 +30,7 @@ public class ScorchSpell extends FireSpell { @Override public boolean update(Caster source) { - BlockPos pos = PosHelper.findSolidGroundAt(source.getWorld(), source.getOrigin()); + BlockPos pos = PosHelper.findSolidGroundAt(source.getWorld(), source.getOrigin(), source.getPhysics().getGravitySignum()); BlockState state = source.getWorld().getBlockState(pos); diff --git a/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java b/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java index 95ff99b5..483a2266 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java +++ b/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java @@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.util.shape.Shape; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Direction.Axis; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; @@ -26,10 +27,9 @@ public interface PosHelper { return a.add(b.getX(), b.getY(), b.getZ()); } - static BlockPos findSolidGroundAt(World world, BlockPos pos) { - while ((pos.getY() > 0 || !World.isInBuildLimit(pos)) - && (world.isAir(pos) || !world.getBlockState(pos).canPlaceAt(world, pos))) { - pos = pos.down(); + static BlockPos findSolidGroundAt(World world, BlockPos pos, int signum) { + while (World.isInBuildLimit(pos) && (world.isAir(pos) || !world.getBlockState(pos).canPlaceAt(world, pos))) { + pos = pos.offset(Axis.Y, -signum); } return pos;