mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Added a rabbit behaviour
This commit is contained in:
parent
80cf905eb0
commit
2fd97fedcf
3 changed files with 34 additions and 0 deletions
|
@ -218,6 +218,7 @@ public class EntityBehaviour<T extends Entity> {
|
|||
static {
|
||||
register(FallingBlockBehaviour::new, EntityType.FALLING_BLOCK);
|
||||
register(RavagerBehaviour::new, EntityType.RAVAGER);
|
||||
register(RabbitBehaviour::new, EntityType.RABBIT);
|
||||
register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER);
|
||||
register(SheepBehaviour::new, EntityType.SHEEP);
|
||||
register(BeeBehaviour::new, EntityType.BEE);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.Spell;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.RabbitEntity;
|
||||
|
||||
public class RabbitBehaviour extends EntityBehaviour<RabbitEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, RabbitEntity entity, Spell spell) {
|
||||
|
||||
if (source instanceof Pony) {
|
||||
Pony player = (Pony)source;
|
||||
|
||||
if (player.getEntity().isOnGround()) {
|
||||
if (Entity.squaredHorizontalLength(player.getEntity().getVelocity()) > 0.01) {
|
||||
player.getOwner().jump();
|
||||
entity.startJump();
|
||||
}
|
||||
} else if (player.landedChanged()) {
|
||||
entity.startJump();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,6 +75,7 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
private boolean speciesSet;
|
||||
private boolean speciesPersisted;
|
||||
private boolean prevSneaking;
|
||||
private boolean prevLanded;
|
||||
|
||||
@Nullable
|
||||
private Race clientPreferredRace;
|
||||
|
@ -108,6 +109,10 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
return entity.isSneaking() != prevSneaking;
|
||||
}
|
||||
|
||||
public boolean landedChanged() {
|
||||
return entity.isOnGround() != prevLanded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpecies(Race race) {
|
||||
race = race.validate(entity);
|
||||
|
@ -278,6 +283,7 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
}
|
||||
|
||||
prevSneaking = entity.isSneaking();
|
||||
prevLanded = entity.isOnGround();
|
||||
}
|
||||
|
||||
public Optional<Float> onImpact(float distance, float damageMultiplier) {
|
||||
|
|
Loading…
Reference in a new issue