mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Cloud blocks and items with feather falling will always collid with cloud blocks
This commit is contained in:
parent
91e84e7551
commit
976a07800e
2 changed files with 20 additions and 7 deletions
|
@ -4,10 +4,13 @@ import java.util.function.Predicate;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||||
import com.minelittlepony.unicopia.entity.Ponylike;
|
import com.minelittlepony.unicopia.entity.Ponylike;
|
||||||
|
import com.minelittlepony.unicopia.gas.Gas;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
|
|
||||||
public interface EquinePredicates {
|
public interface EquinePredicates {
|
||||||
Predicate<Entity> IS_CLOUD = e -> e instanceof CloudEntity;
|
Predicate<Entity> IS_CLOUD = e -> e instanceof CloudEntity;
|
||||||
|
@ -20,7 +23,11 @@ public interface EquinePredicates {
|
||||||
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies() == Race.CHANGELING);
|
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));
|
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(entity -> ((PlayerEntity)entity).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(entity));
|
||||||
|
|
||||||
Predicate<Entity> ITEM_INTERACT_WITH_CLOUDS = IS_VALID_ITEM.and(RACE_INTERACT_WITH_CLOUDS);
|
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);
|
||||||
|
}));
|
||||||
|
|
||||||
Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = PLAYER_PEGASUS.or(ITEM_INTERACT_WITH_CLOUDS);
|
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_WALK_ON_CLOUDS = entity -> entity instanceof LivingEntity && CloudEntity.getFeatherEnchantStrength((LivingEntity)entity) > 0;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity;
|
import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity;
|
||||||
|
@ -584,12 +585,17 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFeatherEnchantStrength(LivingEntity entity) {
|
public static int getFeatherEnchantStrength(LivingEntity entity) {
|
||||||
for (ItemStack stack : entity.getArmorItems()) {
|
return Streams.stream(entity.getArmorItems())
|
||||||
if (stack != null) {
|
.map(CloudEntity::getFeatherEnchantStrength).filter(i -> i > 0)
|
||||||
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
|
.findFirst()
|
||||||
if (enchantments.containsKey(Enchantments.FEATHER_FALLING)) {
|
.orElse(0);
|
||||||
return enchantments.get(Enchantments.FEATHER_FALLING);
|
}
|
||||||
}
|
|
||||||
|
public static int getFeatherEnchantStrength(ItemStack stack) {
|
||||||
|
if (stack != null && !stack.isEmpty()) {
|
||||||
|
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
|
||||||
|
if (enchantments.containsKey(Enchantments.FEATHER_FALLING)) {
|
||||||
|
return enchantments.get(Enchantments.FEATHER_FALLING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue