Earth ponies can now use the same dash ability as pegasi

This commit is contained in:
Sollace 2023-04-30 15:35:44 +01:00
parent a8c1319572
commit b14e5c0d23
5 changed files with 39 additions and 7 deletions

View file

@ -100,6 +100,12 @@ public class EarthPonyKickAbility implements Ability<Pos> {
return true; return true;
} }
if (type == ActivationType.DOUBLE_TAP && player.asEntity().isOnGround() && player.getMagicalReserves().getMana().get() > 40) {
player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(3.5F, 0.3F));
player.subtractEnergyCost(4);
return true;
}
return false; return false;
} }

View file

@ -16,6 +16,7 @@ import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.particle.*; import com.minelittlepony.unicopia.particle.*;
import com.minelittlepony.unicopia.projectile.ProjectileUtil; import com.minelittlepony.unicopia.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.server.world.BlockDestructionManager;
import com.minelittlepony.unicopia.server.world.ModificationType; import com.minelittlepony.unicopia.server.world.ModificationType;
import com.minelittlepony.unicopia.server.world.UGameRules; import com.minelittlepony.unicopia.server.world.UGameRules;
import com.minelittlepony.unicopia.server.world.WeatherConditions; import com.minelittlepony.unicopia.server.world.WeatherConditions;
@ -32,6 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.*; import net.minecraft.util.math.*;
@ -623,12 +625,20 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
Vec3d orientation = entity.getRotationVec(1).multiply(speed); Vec3d orientation = entity.getRotationVec(1).multiply(speed);
entity.addVelocity(orientation.x, orientation.y, orientation.z); entity.addVelocity(orientation.x, orientation.y, orientation.z);
int damage = TraceHelper.findBlocks(entity, speed + 4, 1, state -> state.isIn(UTags.GLASS_PANES)).stream() boolean isEarthPonySmash = pony.getObservedSpecies().canUseEarth() && !isFlying();
int damage = TraceHelper.findBlocks(entity, speed + 4, 1, state -> (isEarthPonySmash && !state.isAir()) || state.isIn(UTags.GLASS_PANES)).stream()
.flatMap(pos -> BlockPos.streamOutwards(pos, 2, 2, 2)) .flatMap(pos -> BlockPos.streamOutwards(pos, 2, 2, 2))
.filter(pos -> entity.world.getBlockState(pos).isOf(Blocks.GLASS_PANE)) .filter(pos -> (isEarthPonySmash && !entity.world.isAir(pos)) || entity.world.getBlockState(pos).isIn(UTags.GLASS_PANES))
.reduce(0, (u, pos) -> { .reduce(0, (u, pos) -> {
if (pony.canModifyAt(pos, ModificationType.PHYSICAL)) { if (pony.canModifyAt(pos, ModificationType.PHYSICAL)) {
entity.world.breakBlock(pos, true); if (isEarthPonySmash) {
BlockDestructionManager.of(entity.world).damageBlock(pos, (int)entity.world.getRandom().nextTriangular(5, 3));
if (BlockDestructionManager.of(entity.world).getBlockDestruction(pos) >= 9) {
entity.world.breakBlock(pos, true);
}
} else {
entity.world.breakBlock(pos, true);
}
} else { } else {
ParticleUtils.spawnParticles(new MagicParticleEffect(0x00AAFF), entity.world, Vec3d.ofCenter(pos), 15); ParticleUtils.spawnParticles(new MagicParticleEffect(0x00AAFF), entity.world, Vec3d.ofCenter(pos), 15);
} }
@ -638,11 +648,22 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
if (damage > 0) { if (damage > 0) {
pony.subtractEnergyCost(damage / 5F); pony.subtractEnergyCost(damage / 5F);
entity.damage(DamageSource.FLY_INTO_WALL, Math.min(damage, entity.getHealth() - 1)); entity.damage(DamageSource.FLY_INTO_WALL, Math.min(damage, entity.getHealth() - 1));
UCriteria.BREAK_WINDOW.trigger(entity); if (!isEarthPonySmash) {
UCriteria.BREAK_WINDOW.trigger(entity);
}
}
if (isEarthPonySmash) {
pony.findAllEntitiesInRange(speed + 4, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR).forEach(e -> e.damage(MagicalDamageSource.STEAMROLLER, 50));
} }
pony.updateVelocity(); pony.updateVelocity();
pony.playSound(USounds.ENTITY_PLAYER_PEGASUS_DASH, 1);
if (isFlying()) {
pony.playSound(USounds.ENTITY_PLAYER_PEGASUS_DASH, 1);
} else {
pony.playSound(SoundEvents.ENTITY_RAVAGER_STEP, 2, 0.3F);
}
} }
@Override @Override

View file

@ -39,7 +39,7 @@ abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHan
cancellable = true) cancellable = true)
private void onTrySleep(BlockPos pos, CallbackInfoReturnable<Either<PlayerEntity.SleepFailureReason, Unit>> info) { private void onTrySleep(BlockPos pos, CallbackInfoReturnable<Either<PlayerEntity.SleepFailureReason, Unit>> info) {
if (get().getActualSpecies().isNocturnal() && get().asWorld().getGameRules().getBoolean(UGameRules.DO_NOCTURNAL_BAT_PONIES)) { if (get().getActualSpecies().isNocturnal() && get().asWorld().getGameRules().getBoolean(UGameRules.DO_NOCTURNAL_BAT_PONIES)) {
((PlayerEntity)this).sendMessage(Text.translatable("block.minecraft.bed.no_sleep.nocturnal"), true); ((PlayerEntity)this).sendMessage(Text.translatable("block.unicopia.bed.no_sleep.nocturnal"), true);
info.setReturnValue(Either.left(PlayerEntity.SleepFailureReason.OTHER_PROBLEM)); info.setReturnValue(Either.left(PlayerEntity.SleepFailureReason.OTHER_PROBLEM));
} }

View file

@ -21,6 +21,7 @@ public class MagicalDamageSource extends EntityDamageSource {
public static final DamageSource TRIBE_SWAP = new DamageSource("tribe_swap").setOutOfWorld().setUnblockable(); public static final DamageSource TRIBE_SWAP = new DamageSource("tribe_swap").setOutOfWorld().setUnblockable();
public static final DamageSource ZAP_APPLE = create("zap"); public static final DamageSource ZAP_APPLE = create("zap");
public static final DamageSource KICK = create("kick"); public static final DamageSource KICK = create("kick");
public static final DamageSource STEAMROLLER = create("steamroller");
public static final DamageSource SUN = new DamageSource("sun").setBypassesArmor().setFire(); public static final DamageSource SUN = new DamageSource("sun").setBypassesArmor().setFire();
public static final DamageSource SUNLIGHT = new DamageSource("sunlight").setBypassesArmor().setFire(); public static final DamageSource SUNLIGHT = new DamageSource("sunlight").setBypassesArmor().setFire();
public static final DamageSource PETRIFIED = new DamageSource("petrified").setBypassesArmor().setFire(); public static final DamageSource PETRIFIED = new DamageSource("petrified").setBypassesArmor().setFire();

View file

@ -2,7 +2,9 @@
"block.unicopia.bed.not_safe": "You may not rest here, there are enemies nearby", "block.unicopia.bed.not_safe": "You may not rest here, there are enemies nearby",
"block.unicopia.bed.not_tired": "You do not feel tired right now", "block.unicopia.bed.not_tired": "You do not feel tired right now",
"block.minecraft.bed.no_sleep.nocturnal": "You can only sleep in the day or during thunderstorms", "block.unicopia.bed.no_sleep.nocturnal": "You can only sleep in the day or during thunderstorms",
"sleep.not_possible.nocturnal": "No amount of rest can pass this day",
"sleep.skipping_day": "Sleeping through this day",
"ability.unicopia.empty_hooves": "I need to find a jar", "ability.unicopia.empty_hooves": "I need to find a jar",
"ability.unicopia.indoors": "I can't see the sky from here", "ability.unicopia.indoors": "I can't see the sky from here",
@ -533,6 +535,8 @@
"death.attack.black_hole.player": "%1$s got sucked into %2$s's black hole", "death.attack.black_hole.player": "%1$s got sucked into %2$s's black hole",
"death.attack.kick": "%1$s was kicked really hard", "death.attack.kick": "%1$s was kicked really hard",
"death.attack.kick.player": "%2$s kicked %1$s really hard", "death.attack.kick.player": "%2$s kicked %1$s really hard",
"death.attack.steamroller": "%1$s was flattened",
"death.attack.steamroller.player": "%2$s steamrolled %1$s",
"death.attack.stalagmite.pegasus": "%1$s tried to perch on a stalagmite", "death.attack.stalagmite.pegasus": "%1$s tried to perch on a stalagmite",
"death.attack.stalagmite.pegasus.player": "%1$s flew into a stalagmite whilst fighting %2$s", "death.attack.stalagmite.pegasus.player": "%1$s flew into a stalagmite whilst fighting %2$s",