Fixed seaponies moving too quickly

This commit is contained in:
Sollace 2023-11-09 15:08:07 +00:00
parent 873297ca44
commit d3821f1c7c
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 12 additions and 10 deletions

View file

@ -591,11 +591,12 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
return Optional.of(speed.multiply(0.5, 1, 0.5)); return Optional.of(speed.multiply(0.5, 1, 0.5));
} }
if (getCompositeRace().includes(Race.SEAPONY)) { if (getCompositeRace().includes(Race.SEAPONY)) {
float factor = entity.isSwimming() ? 1.132F : 1.232F; float factor = entity.isSwimming() ? 1.132F : 1.0232F;
float max = 0.6F;
return Optional.of(new Vec3d( return Optional.of(new Vec3d(
speed.x * factor, MathHelper.clamp(speed.x * factor, -max, max),
speed.y * 1.101, speed.y * ((speed.y * getPhysics().getGravitySignum()) > 0 ? 1.2 : 1.101),
speed.z * factor MathHelper.clamp(speed.z * factor, -max, max)
)); ));
} }
return Optional.empty(); return Optional.empty();
@ -625,16 +626,16 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
return false; return false;
} }
public int getImplicitEnchantmentLevel(Enchantment enchantment) { public int getImplicitEnchantmentLevel(Enchantment enchantment, int initial) {
if ((enchantment == Enchantments.AQUA_AFFINITY if ((enchantment == Enchantments.AQUA_AFFINITY
|| enchantment == Enchantments.DEPTH_STRIDER || enchantment == Enchantments.DEPTH_STRIDER
|| enchantment == Enchantments.LUCK_OF_THE_SEA || enchantment == Enchantments.LUCK_OF_THE_SEA
|| enchantment == Enchantments.LURE) && getCompositeRace().includes(Race.SEAPONY)) { || enchantment == Enchantments.LURE) && getCompositeRace().includes(Race.SEAPONY)) {
return 3; return MathHelper.clamp(initial + 3, enchantment.getMinLevel(), enchantment.getMaxLevel());
} }
return 0; return initial;
} }
public Optional<Float> modifyDamage(DamageSource cause, float amount) { public Optional<Float> modifyDamage(DamageSource cause, float amount) {

View file

@ -16,9 +16,10 @@ abstract class MixinEnchantmentHelper {
@Inject(method = "getEquipmentLevel", at = @At("RETURN"), cancellable = true) @Inject(method = "getEquipmentLevel", at = @At("RETURN"), cancellable = true)
private static void getEquipmentLevel(Enchantment enchantment, LivingEntity entity, CallbackInfoReturnable<Integer> info) { private static void getEquipmentLevel(Enchantment enchantment, LivingEntity entity, CallbackInfoReturnable<Integer> info) {
Pony.of(entity).ifPresent(pony -> { Pony.of(entity).ifPresent(pony -> {
int implicitLevel = pony.getImplicitEnchantmentLevel(enchantment); int initial = info.getReturnValue();
if (implicitLevel > 0) { int implicitLevel = pony.getImplicitEnchantmentLevel(enchantment, initial);
info.setReturnValue(implicitLevel + info.getReturnValue()); if (implicitLevel != initial) {
info.setReturnValue(implicitLevel);
} }
}); });
} }