Anyone who can use the change form ability can also sign and use the friendship bracelets

This commit is contained in:
Sollace 2023-11-09 23:41:09 +00:00
parent a2c78c2b35
commit 3948bf4a58
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 31 additions and 17 deletions

View file

@ -1,6 +1,8 @@
package com.minelittlepony.unicopia.ability;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable;
@ -8,6 +10,7 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.FriendshipBraceletItem;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
@ -67,12 +70,17 @@ public class ChangeFormAbility implements Ability<Hit> {
return false;
}
player.subtractEnergyCost(5);
Race.Composite composite = player.getCompositeRace();
Race actualRace = player.getSpecies();
player.setSpecies(composite.potential());
player.setSuppressedRace(actualRace.availability().isGrantable() ? actualRace : Race.UNSET);
List<Pony> targets = getTargets(player).toList();
player.subtractEnergyCost(5 * targets.size());
boolean isTransforming = player.getSuppressedRace().isUnset();
targets.forEach(target -> {
Race supressed = target.getSuppressedRace();
if (target == player || supressed.isUnset() == isTransforming) {
Race actualRace = target.getSpecies();
target.setSpecies(supressed.or(player.getCompositeRace().potential()));
target.setSuppressedRace(isTransforming ? actualRace : Race.UNSET);
}
});
return true;
}
@ -80,20 +88,25 @@ public class ChangeFormAbility implements Ability<Hit> {
@Override
public void warmUp(Pony player, AbilitySlot slot) {
player.getMagicalReserves().getExertion().addPercent(6);
getTargets(player).forEach(target -> {
if (player.getAbilities().getStat(slot).getWarmup() % 5 == 0) {
player.asWorld().playSound(null, player.getOrigin(), SoundEvents.BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE, SoundCategory.PLAYERS);
player.asWorld().playSound(target.asEntity(), target.getOrigin(), SoundEvents.BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE, SoundCategory.PLAYERS);
}
if (player.asWorld().random.nextInt(5) == 0) {
player.asWorld().playSound(null, player.getOrigin(), USounds.Vanilla.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, SoundCategory.PLAYERS);
player.asWorld().playSound(target.asEntity(), target.getOrigin(), USounds.Vanilla.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, SoundCategory.PLAYERS);
}
player.spawnParticles(ParticleTypes.BUBBLE_COLUMN_UP, 15);
player.spawnParticles(ParticleTypes.BUBBLE_POP, 15);
target.spawnParticles(ParticleTypes.BUBBLE_COLUMN_UP, 15);
target.spawnParticles(ParticleTypes.BUBBLE_POP, 15);
});
}
@Override
public void coolDown(Pony player, AbilitySlot slot) {
}
private Stream<Pony> getTargets(Pony player) {
return Stream.concat(Stream.of(player), FriendshipBraceletItem.getPartyMembers(player, 3));
}
}

View file

@ -247,7 +247,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
setSuppressedRace(Race.UNSET);
}
private Race getSuppressedRace() {
public Race getSuppressedRace() {
return Race.fromName(entity.getDataTracker().get(SUPPRESSED_RACE), Race.UNSET);
}

View file

@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
import com.minelittlepony.unicopia.entity.AmuletSelectors;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.api.EnvType;
@ -37,7 +38,7 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem,
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
ItemStack stack = player.getStackInHand(hand);
if (!isSigned(stack) && EquinePredicates.PLAYER_UNICORN.test(player)) {
if (!isSigned(stack) && (EquinePredicates.PLAYER_UNICORN.test(player) || AmuletSelectors.PEARL_NECKLACE.test(player))) {
player.setCurrentHand(hand);
ItemStack result = stack.copy();