2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-04-26 14:46:03 +02:00
|
|
|
import java.util.function.Predicate;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-06-26 11:44:47 +02:00
|
|
|
import com.minelittlepony.unicopia.equine.Ponylike;
|
|
|
|
import com.minelittlepony.unicopia.world.block.gas.Gas;
|
|
|
|
import com.minelittlepony.unicopia.world.entity.CloudEntity;
|
2020-04-26 19:51:30 +02:00
|
|
|
|
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;
|
2020-04-26 14:46:03 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2020-04-26 19:51:30 +02:00
|
|
|
import net.minecraft.item.BlockItem;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
public interface EquinePredicates {
|
2020-04-26 14:46:03 +02:00
|
|
|
Predicate<Entity> IS_CLOUD = e -> e instanceof CloudEntity;
|
|
|
|
Predicate<Entity> IS_PLAYER = e -> e instanceof PlayerEntity;
|
|
|
|
Predicate<Entity> IS_VALID_ITEM = entity -> entity instanceof ItemEntity && entity.isAlive() && entity.age > 1;
|
|
|
|
|
|
|
|
Predicate<Entity> RACE_INTERACT_WITH_CLOUDS = entity -> Ponylike.of(entity).getSpecies().canInteractWithClouds();
|
|
|
|
|
|
|
|
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies().canCast());
|
|
|
|
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies() == Race.CHANGELING);
|
|
|
|
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(entity -> ((PlayerEntity)entity).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(entity));
|
|
|
|
|
2020-04-26 19:51:30 +02:00
|
|
|
Predicate<Entity> ITEM_INTERACT_WITH_CLOUDS = IS_VALID_ITEM.and(RACE_INTERACT_WITH_CLOUDS.or(e -> {
|
|
|
|
return CloudEntity.getFeatherEnchantStrength(((ItemEntity)e).getStack()) > 0
|
|
|
|
|| (((ItemEntity)e).getStack().getItem() instanceof BlockItem
|
|
|
|
&& ((BlockItem)((ItemEntity)e).getStack().getItem()).getBlock() instanceof Gas);
|
|
|
|
}));
|
2020-04-26 14:46:03 +02:00
|
|
|
|
|
|
|
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = PLAYER_PEGASUS.or(ITEM_INTERACT_WITH_CLOUDS);
|
|
|
|
Predicate<Entity> ENTITY_WALK_ON_CLOUDS = entity -> entity instanceof LivingEntity && CloudEntity.getFeatherEnchantStrength((LivingEntity)entity) > 0;
|
|
|
|
|
|
|
|
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUD_BLOCKS = IS_CLOUD.or(PLAYER_PEGASUS).or(ENTITY_WALK_ON_CLOUDS).or(ITEM_INTERACT_WITH_CLOUDS).or(entity -> {
|
|
|
|
return entity != null && EquinePredicates.ENTITY_INTERACT_WITH_CLOUD_BLOCKS.test(entity.getVehicle());
|
|
|
|
});
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|