Downhill from here

This commit is contained in:
2022-05-12 18:47:53 +02:00
commit a1f3a5985d
8 changed files with 368 additions and 0 deletions
@@ -0,0 +1,30 @@
package me.youhavetrouble.entiddy.SpecialEntities;
import me.youhavetrouble.entiddy.EntiddyInterface;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Rabbit;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.jetbrains.annotations.NotNull;
public class KillerBunny implements EntiddyInterface {
@Override
public Entity spawn(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason spawnReason) {
if (location.getWorld() == null) {
throw new NullPointerException("World cannot be null");
}
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason, (entity) -> {
Rabbit rabbit = (Rabbit) entity;
rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
});
}
@Override
public boolean isInstance(LivingEntity entity) {
if (!(entity instanceof Rabbit)) return false;
return ((Rabbit) entity).getRabbitType().equals(Rabbit.Type.THE_KILLER_BUNNY);
}
}