Changelings can now climb walls. Closes #122

This commit is contained in:
Sollace 2023-08-06 18:56:31 +01:00
parent ca792dc4d2
commit db69d649a5
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 25 additions and 8 deletions

View file

@ -15,8 +15,10 @@ import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
import com.minelittlepony.unicopia.ability.magic.SpellContainer.Operation;
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck;
import com.minelittlepony.unicopia.entity.effect.UEffects;
import com.minelittlepony.unicopia.entity.player.Pony;
@ -328,6 +330,13 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
return Optional.empty();
}
public Optional<BlockPos> chooseClimbingPos() {
return getSpellSlot().get(SpellPredicate.IS_DISGUISE, false)
.map(AbstractDisguiseSpell::getDisguise)
.filter(EntityAppearance::canClimbWalls)
.map(v -> entity.getBlockPos());
}
private boolean tryCaptureLightning() {
return getInventoryStacks().filter(stack -> !stack.isEmpty() && stack.getItem() == UItems.EMPTY_JAR).findFirst().map(stack -> {
invinsibilityTicks = 20;

View file

@ -171,7 +171,6 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
if (animation.isOf(Animation.NONE)) {
return 0;
}
System.out.println(animationMaxDuration);
return 1 - (((float)animationDuration) / animationMaxDuration);
}
@ -360,6 +359,11 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
powers.tick();
if (entity.getClimbingPos().isPresent() && entity.isSneaky()) {
Vec3d vel = entity.getVelocity();
entity.setVelocity(vel.x, 0, vel.z);
}
return false;
}
@ -397,6 +401,14 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
return state.isSolidSurface(asWorld(), pos, entity, Direction.DOWN);
}
@Override
public Optional<BlockPos> chooseClimbingPos() {
if (getObservedSpecies() == Race.CHANGELING && getSpellSlot().get(SpellPredicate.IS_DISGUISE, false).isEmpty()) {
return Optional.of(entity.getBlockPos());
}
return super.chooseClimbingPos();
}
private void updateAnimations() {
if (animationDuration > 0 && --animationDuration <= 0) {
setAnimation(AnimationInstance.NONE);

View file

@ -17,7 +17,6 @@ import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.entity.*;
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
import com.minelittlepony.unicopia.entity.duck.*;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@ -85,12 +84,9 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ
@Inject(method = "isClimbing()Z", at = @At("HEAD"), cancellable = true)
public void onIsClimbing(CallbackInfoReturnable<Boolean> info) {
if (get() instanceof Pony && horizontalCollision) {
((Pony)get()).getSpellSlot().get(SpellPredicate.IS_DISGUISE, false)
.map(AbstractDisguiseSpell::getDisguise)
.filter(EntityAppearance::canClimbWalls)
.ifPresent(v -> {
climbingPos = Optional.of(getBlockPos());
if (horizontalCollision) {
get().chooseClimbingPos().ifPresent(pos -> {
climbingPos = Optional.of(pos);
info.setReturnValue(true);
});
}