mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Added simple behaviours for horses
This commit is contained in:
parent
db23786b70
commit
92bf11b87c
3 changed files with 30 additions and 8 deletions
|
@ -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) {
|
||||
if (source instanceof Pony) {
|
||||
owner.setInvisible(false);
|
||||
if (source instanceof Pony) {
|
||||
((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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue