Pegasi dashing can now smash through windows

This commit is contained in:
Sollace 2022-10-01 18:21:33 +02:00
parent 8c65adeea2
commit 8e052f2472

View file

@ -15,13 +15,9 @@ import com.minelittlepony.unicopia.item.AmuletItem;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.projectile.ProjectileUtil; import com.minelittlepony.unicopia.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.*;
import com.minelittlepony.unicopia.util.Tickable;
import com.minelittlepony.unicopia.util.AnimationUtil;
import com.minelittlepony.unicopia.util.MutableVector;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityPose;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
@ -35,9 +31,7 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
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.BlockPos; import net.minecraft.util.math.*;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickable, Motion, NbtSerialisable { public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickable, Motion, NbtSerialisable {
private static final int MAX_WALL_HIT_CALLDOWN = 30; private static final int MAX_WALL_HIT_CALLDOWN = 30;
@ -594,6 +588,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.isOf(Blocks.GLASS_PANE)).stream()
.flatMap(pos -> BlockPos.streamOutwards(pos, 2, 2, 2))
.filter(pos -> entity.world.getBlockState(pos).isOf(Blocks.GLASS_PANE))
.reduce(0, (u, pos) -> {
entity.world.breakBlock(pos, true);
return 1;
}, Integer::sum);
if (damage > 0) {
pony.subtractEnergyCost(damage / 5F);
entity.damage(DamageSource.FLY_INTO_WALL, Math.min(damage, entity.getHealth() - 1));
}
pony.updateVelocity(); pony.updateVelocity();
pony.playSound(USounds.ENTITY_PLAYER_PEGASUS_DASH, 1); pony.playSound(USounds.ENTITY_PLAYER_PEGASUS_DASH, 1);
} }