mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Only trigger the creeper's action when not flying
This commit is contained in:
parent
804403ce25
commit
085c9dac2f
1 changed files with 8 additions and 1 deletions
|
@ -3,12 +3,14 @@ package com.minelittlepony.unicopia.entity.behaviour;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Spell;
|
import com.minelittlepony.unicopia.ability.magic.Spell;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.mob.CreeperEntity;
|
import net.minecraft.entity.mob.CreeperEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
||||||
@Override
|
@Override
|
||||||
public void update(Caster<?> source, CreeperEntity entity, Spell spell) {
|
public void update(Caster<?> source, CreeperEntity entity, Spell spell) {
|
||||||
if (source.getEntity().isSneaking()) {
|
if (isSneakingOnGround(source)) {
|
||||||
entity.setFuseSpeed(1);
|
entity.setFuseSpeed(1);
|
||||||
} else {
|
} else {
|
||||||
entity.setFuseSpeed(-1);
|
entity.setFuseSpeed(-1);
|
||||||
|
@ -16,4 +18,9 @@ public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
||||||
entity.getVisibilityCache().clear();
|
entity.getVisibilityCache().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isSneakingOnGround(Caster<?> source) {
|
||||||
|
Entity e = source.getEntity();
|
||||||
|
return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).abilities.flying));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue