diff --git a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java index cc810efa..ce4d4bce 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.advancement.UCriteria; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.util.MagicalDamageSource; @@ -79,15 +80,16 @@ public class BatEeeeAbility implements Ability { } int total = player.findAllEntitiesInRange(5).mapToInt(e -> { - if (e instanceof LivingEntity && !SpellType.SHIELD.isOn(e)) { + if (e instanceof LivingEntity living && !SpellType.SHIELD.isOn(e)) { boolean isEarthPony = EquinePredicates.PLAYER_EARTH.test(e); e.damage(MagicalDamageSource.create("eeee", player).setBreakSunglasses(), isEarthPony ? 0.1F : 0.3F); Vec3d knockVec = origin.subtract(e.getPos()); - ((LivingEntity) e).takeKnockback(isEarthPony ? 0.3F : 0.5F, knockVec.getX(), knockVec.getZ()); + living.takeKnockback(isEarthPony ? 0.3F : 0.5F, knockVec.getX(), knockVec.getZ()); if (!isEarthPony) { e.addVelocity(0, 0.1, 0); } + Living.updateVelocity(e); } return 1; }).sum(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 10c48cee..fa42717c 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.ability.data.tree.TreeType; import com.minelittlepony.unicopia.block.data.BlockDestructionManager; import com.minelittlepony.unicopia.client.minelittlepony.MineLPDelegate; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.UParticles; @@ -84,6 +85,7 @@ public class EarthPonyKickAbility implements Ability { float calculatedStrength = 0.5F * (1 + player.getLevel().getScaled(9)); entity.damage(MagicalDamageSource.KICK, player.getReferenceWorld().random.nextBetween(2, 10) + calculatedStrength); entity.takeKnockback(calculatedStrength, origin.x - entity.getX(), origin.z - entity.getZ()); + Living.updateVelocity(entity); player.subtractEnergyCost(3); player.setAnimation(Animation.KICK); return; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 7ccc4257..e52a8d86 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.block.data.BlockDestructionManager; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.enchantment.UEnchantments; @@ -85,6 +86,7 @@ public class EarthPonyStompAbility implements Ability { double downV = Math.sqrt(ppos.getSquaredDistance(pos)) * player.getPhysics().getGravitySignum(); player.getMaster().addVelocity(0, -downV, 0); + player.updateVelocity(); } @Override @@ -138,6 +140,7 @@ public class EarthPonyStompAbility implements Ability { } i.damage(damage, (float)amount); + Living.updateVelocity(i); } }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index aa2ec307..2a9d800d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -2,8 +2,7 @@ package com.minelittlepony.unicopia.ability; import org.jetbrains.annotations.Nullable; -import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.USounds; +import com.minelittlepony.unicopia.*; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.HomingSpell; import com.minelittlepony.unicopia.ability.magic.spell.Spell; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractionUtils.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractionUtils.java index d4d1c19d..edb5e78b 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractionUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractionUtils.java @@ -1,5 +1,6 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.enchantment.UEnchantments; @@ -37,6 +38,7 @@ public interface AttractionUtils { center.y + yChange, center.z ); + Living.updateVelocity(target); } /** diff --git a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java index c5fddc3e..bebf30f2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java @@ -148,6 +148,8 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C e.setVelocity(vel.getX(), yVel, vel.getZ()); e.setVelocity(e.getVelocity().multiply(0.3).add(getVelocity().multiply(0.786))); e.setOnGround(true); + + Living.updateVelocity(e); } } @@ -163,6 +165,7 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C @Override public void onPlayerCollision(PlayerEntity player) { + // TODO: check that this is still working correctly after adding Living.updateVelocity(i) in AirBalloonEntity.tick() if (getVelocity().lengthSquared() > 0) { // player.setVelocity(getVelocity().multiply(1.3)); player.setVelocity(player.getVelocity().multiply(0.3).add(getVelocity().multiply( @@ -174,6 +177,8 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C if (diff > 0) { player.addVelocity(0, diff, 0); } + + Living.updateVelocity(player); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java index 9c63fedb..78ae10e0 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java @@ -9,8 +9,7 @@ import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.AwaitTickQueue; import com.minelittlepony.unicopia.USounds; -import com.minelittlepony.unicopia.entity.IItemEntity; -import com.minelittlepony.unicopia.entity.ItemImpl; +import com.minelittlepony.unicopia.entity.*; import com.minelittlepony.unicopia.entity.effect.UEffects; import com.minelittlepony.unicopia.entity.player.MagicReserves; import com.minelittlepony.unicopia.entity.player.PlayerCharmTracker; @@ -133,6 +132,7 @@ public class AlicornAmuletItem extends AmuletItem implements PlayerCharmTracker. if (attachedTime > 120) { pony.getMaster().takeKnockback(1, 1, 1); + pony.updateVelocity(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java index 82a442c2..0857d740 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.item; import com.minelittlepony.unicopia.entity.IItemEntity; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import net.minecraft.block.Block; @@ -89,12 +90,13 @@ public class FilledJarItem extends JarItem implements ChameleonItem { final float toRadians = (float)Math.PI / 180F; - if (entity instanceof LivingEntity) { - ((LivingEntity)entity).takeKnockback( + if (entity instanceof LivingEntity living) { + living.takeKnockback( knockback / 2F, MathHelper.sin(projectile.getYaw() * toRadians), -MathHelper.cos(projectile.getYaw() * toRadians) ); + Living.updateVelocity(living); if (fire > 0) { entity.setOnFireFor(fire * 4); diff --git a/src/main/java/com/minelittlepony/unicopia/item/PolearmItem.java b/src/main/java/com/minelittlepony/unicopia/item/PolearmItem.java index 031c3e21..e0a4b0c0 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PolearmItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/PolearmItem.java @@ -5,6 +5,7 @@ import java.util.UUID; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; import com.minelittlepony.unicopia.UTags; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.UEntityAttributes; import net.minecraft.block.*; @@ -12,8 +13,6 @@ import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.*; import net.minecraft.item.*; -import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; public class PolearmItem extends SwordItem { protected static final UUID ATTACK_RANGE_MODIFIER_ID = UUID.fromString("A7B3659C-AA74-469C-963A-09A391DCAA0F"); @@ -57,11 +56,10 @@ public class PolearmItem extends SwordItem { boolean tooNear = target.distanceTo(attacker) <= 2; stack.damage(tooNear ? 4 : 1, attacker, e -> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); target.takeKnockback(0.15, attacker.getX() - target.getX(), attacker.getZ() - target.getZ()); + Living.updateVelocity(target); if (tooNear) { attacker.takeKnockback(attacker.getRandom().nextTriangular(0.4, 0.2), target.getX() - attacker.getX(), target.getZ() - attacker.getZ()); - if (attacker instanceof ServerPlayerEntity ply) { - ply.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(ply)); - } + Living.updateVelocity(attacker); } return true; diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/ProjectileUtil.java b/src/main/java/com/minelittlepony/unicopia/projectile/ProjectileUtil.java index 9d90c729..889a6086 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/ProjectileUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/ProjectileUtil.java @@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.projectile; import org.jetbrains.annotations.Nullable; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.mixin.MixinPersistentProjectileEntity; import net.minecraft.entity.Entity; @@ -50,6 +51,7 @@ public interface ProjectileUtil { Vec3d vel = throwable.getVelocity(); throwable.addVelocity(heading.x - vel.x, heading.y - vel.y, heading.z - vel.z); + Living.updateVelocity(throwable); } }