Only trigger the creeper's action when not flying

This commit is contained in:
Sollace 2020-09-24 20:03:05 +02:00
parent 804403ce25
commit 085c9dac2f

View file

@ -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));
}
} }