mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-05 17:51:29 +01:00
#317 +Allow bats and hippos to walk on clouds without having to give them other pegasus abilities
Separate cloud interaction and ability to collect weather jars/use rainboom ability into two flags
This commit is contained in:
parent
a4fb5e7ae7
commit
aa1973181f
7 changed files with 30 additions and 8 deletions
src/main/java/com/minelittlepony/unicopia
|
@ -22,7 +22,7 @@ public interface EquineContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean collidesWithClouds() {
|
default boolean collidesWithClouds() {
|
||||||
return getCompositeRace().any(Race::canInteractWithClouds);
|
return getCompositeRace().canInteractWithClouds();
|
||||||
}
|
}
|
||||||
|
|
||||||
static EquineContext of(ShapeContext context) {
|
static EquineContext of(ShapeContext context) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ public interface EquinePredicates {
|
||||||
Predicate<Entity> BAT = physicalRaceMatches(Race.BAT::equals);
|
Predicate<Entity> BAT = physicalRaceMatches(Race.BAT::equals);
|
||||||
Predicate<Entity> CHANGELING = physicalRaceMatches(Race.CHANGELING::equals);
|
Predicate<Entity> CHANGELING = physicalRaceMatches(Race.CHANGELING::equals);
|
||||||
|
|
||||||
Predicate<Entity> RACE_INTERACT_WITH_CLOUDS = raceMatches(Race::canInteractWithClouds);
|
Predicate<Entity> RACE_CAN_INFLUENCE_WEATHER = raceMatches(Race::canInfluenceWeather);
|
||||||
Predicate<Entity> RAGING = IS_PLAYER.and(SpellType.RAGE::isOn);
|
Predicate<Entity> RAGING = IS_PLAYER.and(SpellType.RAGE::isOn);
|
||||||
|
|
||||||
Predicate<Entity> PLAYER_EARTH = IS_PLAYER.and(ofRace(Race.EARTH));
|
Predicate<Entity> PLAYER_EARTH = IS_PLAYER.and(ofRace(Race.EARTH));
|
||||||
|
@ -28,7 +28,6 @@ public interface EquinePredicates {
|
||||||
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(raceMatches(Race::canCast));
|
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(raceMatches(Race::canCast));
|
||||||
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(ofRace(Race.CHANGELING));
|
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(ofRace(Race.CHANGELING));
|
||||||
Predicate<Entity> PLAYER_KIRIN = IS_PLAYER.and(ofRace(Race.KIRIN));
|
Predicate<Entity> PLAYER_KIRIN = IS_PLAYER.and(ofRace(Race.KIRIN));
|
||||||
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(e -> ((PlayerEntity)e).getAbilities().creativeMode || RACE_INTERACT_WITH_CLOUDS.test(e));
|
|
||||||
Predicate<Entity> PLAYER_SEAPONY = IS_PLAYER.and(raceMatches(Race::isFish));
|
Predicate<Entity> PLAYER_SEAPONY = IS_PLAYER.and(raceMatches(Race::isFish));
|
||||||
|
|
||||||
Predicate<Entity> PLAYER_CAN_USE_EARTH = IS_PLAYER.and(raceMatches(Race::canUseEarth));
|
Predicate<Entity> PLAYER_CAN_USE_EARTH = IS_PLAYER.and(raceMatches(Race::canUseEarth));
|
||||||
|
|
|
@ -108,9 +108,17 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canInteractWithClouds() {
|
public boolean canInteractWithClouds() {
|
||||||
|
return canFly() && this != CHANGELING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canInfluenceWeather() {
|
||||||
return canFly() && this != CHANGELING && this != BAT && this != HIPPOGRIFF;
|
return canFly() && this != CHANGELING && this != BAT && this != HIPPOGRIFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasPersistentWeatherMagic() {
|
||||||
|
return canInfluenceWeather();
|
||||||
|
}
|
||||||
|
|
||||||
public Identifier getId() {
|
public Identifier getId() {
|
||||||
return REGISTRY.getId(this);
|
return REGISTRY.getId(this);
|
||||||
}
|
}
|
||||||
|
@ -225,6 +233,18 @@ public record Race (Supplier<Composite> compositeSupplier, Availability availabi
|
||||||
return any(Race::canCast);
|
return any(Race::canCast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canInteractWithClouds() {
|
||||||
|
return any(Race::canInteractWithClouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canInfluenceWeather() {
|
||||||
|
return any(Race::canInfluenceWeather);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPersistentWeatherMagic() {
|
||||||
|
return any(Race::hasPersistentWeatherMagic);
|
||||||
|
}
|
||||||
|
|
||||||
public FlightType flightType() {
|
public FlightType flightType() {
|
||||||
if (pseudo() == null) {
|
if (pseudo() == null) {
|
||||||
return physical().flightType();
|
return physical().flightType();
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(Race race) {
|
public boolean canUse(Race race) {
|
||||||
return race.canInteractWithClouds();
|
return race.canInfluenceWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class PegasusRainboomAbility implements Ability<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(Race race) {
|
public boolean canUse(Race race) {
|
||||||
return race.canInteractWithClouds();
|
return race.canInfluenceWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean collidesWithClouds() {
|
public boolean collidesWithClouds() {
|
||||||
return entity.getStack().isIn(UTags.FLOATS_ON_CLOUDS) || getSpecies().canInteractWithClouds();
|
return entity.getStack().isIn(UTags.FLOATS_ON_CLOUDS) || getSpecies().hasPersistentWeatherMagic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,8 +39,11 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem,
|
||||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack stack = player.getStackInHand(hand);
|
ItemStack stack = player.getStackInHand(hand);
|
||||||
|
|
||||||
if (!isSigned(stack) && (EquinePredicates.PLAYER_UNICORN.test(player) || EquinePredicates.PLAYER_PEGASUS.test(player)
|
if (!isSigned(stack) && (
|
||||||
|| AmuletSelectors.PEARL_NECKLACE.test(player))) {
|
EquinePredicates.PLAYER_UNICORN.test(player)
|
||||||
|
|| EquinePredicates.RACE_CAN_INFLUENCE_WEATHER.test(player)
|
||||||
|
|| AmuletSelectors.PEARL_NECKLACE.test(player)
|
||||||
|
)) {
|
||||||
player.setCurrentHand(hand);
|
player.setCurrentHand(hand);
|
||||||
|
|
||||||
ItemStack result = stack.copy();
|
ItemStack result = stack.copy();
|
||||||
|
|
Loading…
Add table
Reference in a new issue