2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
|
|
|
import com.google.common.base.Predicate;
|
2020-04-15 18:12:00 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.Ponylike;
|
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.entity.ItemEntity;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
public interface EquinePredicates {
|
|
|
|
Predicate<PlayerEntity> INTERACT_WITH_CLOUDS = player -> {
|
2020-04-15 18:12:00 +02:00
|
|
|
return player != null && Pony.of(player).getSpecies().canInteractWithClouds();
|
2018-09-16 00:45:44 +02:00
|
|
|
};
|
2018-09-19 09:07:39 +02:00
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
Predicate<Entity> MAGI = entity -> {
|
2020-04-15 18:12:00 +02:00
|
|
|
return entity instanceof PlayerEntity && Pony.of((PlayerEntity)entity).getSpecies().canCast();
|
2018-09-19 09:07:39 +02:00
|
|
|
};
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
Predicate<Entity> ITEMS = entity -> {
|
2020-01-16 12:35:46 +01:00
|
|
|
return entity instanceof ItemEntity && entity.isAlive() && entity.age > 1;
|
2018-09-19 10:17:18 +02:00
|
|
|
};
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
Predicate<ItemEntity> ITEM_INTERACT_WITH_CLOUDS = item -> {
|
2020-04-15 18:12:00 +02:00
|
|
|
return ITEMS.test(item) && Ponylike.of(item).getSpecies().canInteractWithClouds();
|
2018-09-16 00:45:44 +02:00
|
|
|
};
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = entity -> {
|
2018-09-16 00:45:44 +02:00
|
|
|
return entity != null && (
|
2020-01-16 12:35:46 +01:00
|
|
|
(entity instanceof PlayerEntity && INTERACT_WITH_CLOUDS.test((PlayerEntity)entity))
|
|
|
|
|| (entity instanceof ItemEntity && ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)entity))
|
2018-09-16 00:45:44 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
Predicate<Entity> BUGGY = entity -> {
|
2020-01-16 12:35:46 +01:00
|
|
|
return entity instanceof PlayerEntity
|
2020-04-15 18:12:00 +02:00
|
|
|
&& Pony.of((PlayerEntity)entity).getSpecies() == Race.CHANGELING;
|
2019-03-03 23:33:40 +01:00
|
|
|
};
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
static PlayerEntity getPlayerFromEntity(Entity entity) {
|
2020-01-16 12:35:46 +01:00
|
|
|
if (entity instanceof PlayerEntity) {
|
|
|
|
return (PlayerEntity) entity;
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
if (entity instanceof ItemEntity) {
|
|
|
|
ItemEntity item = (ItemEntity)entity;
|
2018-09-16 00:45:44 +02:00
|
|
|
if (item.getOwner() != null) {
|
2020-01-16 12:35:46 +01:00
|
|
|
return item.getEntityWorld().getPlayerByUuid(item.getOwner());
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|