mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed ground pound not taking into accoutn the player's gravity
This commit is contained in:
parent
f0e43cdbe7
commit
0cd45ad1ae
3 changed files with 15 additions and 15 deletions
|
@ -58,8 +58,8 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
|||
@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<Hit> {
|
|||
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<Hit> {
|
|||
}
|
||||
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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue