From 085c9dac2f1f691822782ca015a86778a06350cb Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 24 Sep 2020 20:03:05 +0200 Subject: [PATCH] Only trigger the creeper's action when not flying --- .../unicopia/entity/behaviour/CreeperBehaviour.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/CreeperBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/CreeperBehaviour.java index 99094449..2f5c99cb 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/CreeperBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/CreeperBehaviour.java @@ -3,12 +3,14 @@ package com.minelittlepony.unicopia.entity.behaviour; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; +import net.minecraft.entity.Entity; import net.minecraft.entity.mob.CreeperEntity; +import net.minecraft.entity.player.PlayerEntity; public class CreeperBehaviour extends EntityBehaviour { @Override public void update(Caster source, CreeperEntity entity, Spell spell) { - if (source.getEntity().isSneaking()) { + if (isSneakingOnGround(source)) { entity.setFuseSpeed(1); } else { entity.setFuseSpeed(-1); @@ -16,4 +18,9 @@ public class CreeperBehaviour extends EntityBehaviour { entity.getVisibilityCache().clear(); } } + + protected boolean isSneakingOnGround(Caster source) { + Entity e = source.getEntity(); + return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).abilities.flying)); + } }