Unicopia/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java

53 lines
2 KiB
Java
Raw Normal View History

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 {
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) {
int count = 1 + rng.nextInt(10) + (int)(strength * 10);
2020-09-25 20:24:48 +02:00
for (int i = 0; i < count; i++) {
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());
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());
}, rng.nextInt(3));
2020-09-25 20:24:48 +02:00
}
}
2020-09-25 20:24:48 +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);
UCriteria.SCREECH_SELF.trigger(player.asEntity());
2020-09-25 20:24:48 +02:00
}
}
}