Added simple behaviours for horses

This commit is contained in:
Sollace 2020-10-02 14:04:31 +02:00
parent db23786b70
commit 92bf11b87c
3 changed files with 30 additions and 8 deletions

View file

@ -5,7 +5,6 @@ import java.util.Optional;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Affinity;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.ability.FlightPredicate;
import com.minelittlepony.unicopia.ability.DimensionsPredicate;
@ -133,8 +132,8 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
}
if (entity == null) {
owner.setInvisible(false);
if (source instanceof Pony) {
owner.setInvisible(false);
((Pony) source).setInvisible(false);
}
@ -164,8 +163,8 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
if (source instanceof Pony) {
Pony player = (Pony)source;
player.setInvisible(true);
source.getOwner().setInvisible(true);
player.setInvisible(true);
if (entity instanceof Owned) {
((Owned<LivingEntity>)entity).setOwner(player.getOwner());
@ -174,11 +173,6 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup
if (entity instanceof PlayerEntity) {
entity.getDataTracker().set(PlayerAccess.getModelBitFlag(), owner.getDataTracker().get(PlayerAccess.getModelBitFlag()));
}
if (player.isClientPlayer() && InteractionManager.instance().getViewMode() == 0) {
entity.setInvisible(true);
entity.setPos(entity.getX(), Integer.MIN_VALUE, entity.getY());
}
}
return !source.getOwner().isDead();

View file

@ -239,6 +239,7 @@ public class EntityBehaviour<T extends Entity> {
register(MobBehaviour::new, EntityType.RAVAGER, EntityType.IRON_GOLEM);
register(HoppingBehaviour::new, EntityType.RABBIT, EntityType.SLIME, EntityType.MAGMA_CUBE);
register(TraderBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER);
register(SteedBehaviour::new, EntityType.HORSE, EntityType.DONKEY, EntityType.SKELETON_HORSE, EntityType.ZOMBIE_HORSE);
register(SheepBehaviour::new, EntityType.SHEEP);
register(BeeBehaviour::new, EntityType.BEE);
register(GhastBehaviour::new, EntityType.GHAST);

View file

@ -0,0 +1,27 @@
package com.minelittlepony.unicopia.entity.behaviour;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.JumpingMount;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.HorseBaseEntity;
public class SteedBehaviour<T extends LivingEntity & JumpingMount> extends EntityBehaviour<T> {
@Override
public void update(Pony player, T entity, DisguiseSpell spell) {
HorseBaseEntity horse = ((HorseBaseEntity)entity);
boolean angry = !player.getEntity().isOnGround() && player.getOwner().isSprinting();
boolean sneaking = isSneakingOnGround(player);
angry |= sneaking;
if (player.sneakingChanged() && sneaking) {
horse.playAngrySound();
}
horse.setAngry(angry);
}
}