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));
}
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(
speed.x * factor,
speed.y * 1.101,
speed.z * factor
MathHelper.clamp(speed.x * factor, -max, max),
speed.y * ((speed.y * getPhysics().getGravitySignum()) > 0 ? 1.2 : 1.101),
MathHelper.clamp(speed.z * factor, -max, max)
));
}
return Optional.empty();
@ -625,16 +626,16 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
return false;
}
public int getImplicitEnchantmentLevel(Enchantment enchantment) {
public int getImplicitEnchantmentLevel(Enchantment enchantment, int initial) {
if ((enchantment == Enchantments.AQUA_AFFINITY
|| enchantment == Enchantments.DEPTH_STRIDER
|| enchantment == Enchantments.LUCK_OF_THE_SEA
|| 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) {

View file

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