From 33dc4cbb34705b1247d525663eaaa267a0d574d4 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 24 Dec 2022 21:13:20 +0100 Subject: [PATCH] Fix some balancing issues for changling's love draining ability and add sound effects --- .../ability/ChangelingFeedAbility.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 43e9462b..a3bc6583 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -27,6 +27,7 @@ import net.minecraft.entity.passive.PigEntity; import net.minecraft.entity.passive.SheepEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; +import net.minecraft.sound.SoundEvents; /** * Changeling ability to restore health from mobs @@ -61,7 +62,8 @@ public class ChangelingFeedAbility implements Ability { } private boolean canFeed(Pony player) { - return player.asEntity().getHealth() < player.asEntity().getMaxHealth() || player.asEntity().canConsume(false); + return player.asEntity().getHealth() < player.asEntity().getMaxHealth() + || player.asEntity().canConsume(false); } private boolean canDrain(Entity e) { @@ -96,6 +98,10 @@ public class ChangelingFeedAbility implements Ability { @Override public void apply(Pony iplayer, Hit data) { + if (!canFeed(iplayer)) { + return; + } + PlayerEntity player = iplayer.asEntity(); float maximumHealthGain = player.getMaxHealth() - player.getHealth(); @@ -113,12 +119,17 @@ public class ChangelingFeedAbility implements Ability { if (foodAmount > 0) { healAmount -= foodAmount; - player.getHungerManager().add(foodAmount, 0.125f); } + player.getHungerManager().add(Math.max(1, foodAmount), 0.125f); - if (healAmount > 0) { - player.heal(Math.min(healAmount, maximumHealthGain)); - } + player.heal(Math.max(1, Math.min(healAmount, maximumHealthGain))); + } + + + if (!canFeed(iplayer)) { + iplayer.playSound(SoundEvents.ENTITY_PLAYER_BURP, 1, (float)player.world.random.nextTriangular(1F, 0.2F)); + } else { + iplayer.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.1F, iplayer.getRandomPitch()); } }