2020-09-25 20:24:48 +02:00
|
|
|
package com.minelittlepony.unicopia.ability;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.AwaitTickQueue;
|
|
|
|
import com.minelittlepony.unicopia.Race;
|
|
|
|
import com.minelittlepony.unicopia.USounds;
|
2021-08-19 14:43:15 +02:00
|
|
|
import com.minelittlepony.unicopia.advancement.UCriteria;
|
2023-06-02 21:20:30 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
2020-09-25 20:24:48 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
|
|
|
|
2022-06-25 00:19:55 +02:00
|
|
|
import net.minecraft.util.math.random.Random;
|
2023-11-08 13:58:31 +01:00
|
|
|
import net.minecraft.world.event.GameEvent;
|
2020-09-25 20:24:48 +02:00
|
|
|
|
|
|
|
/**
|
2023-11-08 13:58:31 +01:00
|
|
|
* An ability to screeeeeeeeEeEeEeeee!
|
2020-09-25 20:24:48 +02:00
|
|
|
*/
|
2023-11-08 13:58:31 +01:00
|
|
|
public class BatEeeeAbility extends ScreechAbility {
|
2023-08-16 21:55:38 +02:00
|
|
|
public static final int SELF_SPOOK_PROBABILITY = 20000;
|
|
|
|
|
2020-09-25 20:24:48 +02:00
|
|
|
@Override
|
|
|
|
public boolean canUse(Race race) {
|
|
|
|
return race == Race.BAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-08 13:58:31 +01:00
|
|
|
protected void playSounds(Pony player, Random rng, float strength) {
|
2023-08-16 21:55:38 +02:00
|
|
|
int count = 1 + rng.nextInt(10) + (int)(strength * 10);
|
2020-09-25 20:24:48 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2023-08-16 21:55:38 +02:00
|
|
|
player.playSound(USounds.ENTITY_PLAYER_BATPONY_SCREECH,
|
|
|
|
(0.9F + (rng.nextFloat() - 0.5F) / 2F) * strength,
|
2020-09-25 20:24:48 +02:00
|
|
|
1.6F + (rng.nextFloat() - 0.5F)
|
|
|
|
);
|
|
|
|
}
|
2023-11-08 13:58:31 +01:00
|
|
|
player.asWorld().emitGameEvent(player.asEntity(), GameEvent.ENTITY_ROAR, player.asEntity().getEyePos());
|
2023-08-16 21:55:38 +02:00
|
|
|
for (int j = 0; j < (int)(strength * 2); j++) {
|
|
|
|
for (int k = 0; k < count; k++) {
|
|
|
|
AwaitTickQueue.scheduleTask(player.asWorld(), w -> {
|
|
|
|
player.playSound(USounds.ENTITY_PLAYER_BATPONY_SCREECH,
|
|
|
|
(0.9F + (rng.nextFloat() - 0.5F) / 2F) * strength,
|
|
|
|
1.6F + (rng.nextFloat() - 0.5F)
|
|
|
|
);
|
2023-11-08 13:58:31 +01:00
|
|
|
player.asWorld().emitGameEvent(player.asEntity(), GameEvent.ENTITY_ROAR, player.asEntity().getEyePos());
|
2023-08-16 21:55:38 +02:00
|
|
|
}, rng.nextInt(3));
|
2020-09-25 20:24:48 +02:00
|
|
|
}
|
2023-08-16 21:55:38 +02:00
|
|
|
}
|
2020-09-25 20:24:48 +02:00
|
|
|
|
2023-08-16 21:55:38 +02:00
|
|
|
if (strength > 0.5F && rng.nextInt(SELF_SPOOK_PROBABILITY) == 0) {
|
2023-06-02 21:20:30 +02:00
|
|
|
player.asEntity().damage(player.damageOf(UDamageTypes.BAT_SCREECH, player), 0.1F);
|
2022-12-19 16:03:35 +01:00
|
|
|
UCriteria.SCREECH_SELF.trigger(player.asEntity());
|
2020-09-25 20:24:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|