From 7187ad61eeb7165fdaaa3edce16f79a28017446e Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 13 Sep 2023 14:07:39 +0100 Subject: [PATCH] Fixed crash when summoning sombra with commands when on peaceful mode. Closes #187 --- .../unicopia/entity/mob/SombraEntity.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/mob/SombraEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/mob/SombraEntity.java index f9e92d12..e70d4438 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/mob/SombraEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/mob/SombraEntity.java @@ -226,28 +226,30 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti setPersistent(); Optional homePos = getHomePos(); - if (homePos.isEmpty() && !isRemoved()) { + if (homePos.isEmpty()) { setHomePos(getWorld().getTopPosition(Type.MOTION_BLOCKING_NO_LEAVES, getBlockPos())); homePos = getHomePos(); } - if (getBlockPos().getSquaredDistance(homePos.get()) > MathHelper.square(getAreaRadius())) { - teleportTo(Vec3d.ofCenter(homePos.get())); - getNavigation().stop(); - } + if (!isRemoved()) { + if (getBlockPos().getSquaredDistance(homePos.get()) > MathHelper.square(getAreaRadius())) { + teleportTo(Vec3d.ofCenter(homePos.get())); + getNavigation().stop(); + } - prevBiteTime = biteTime; - if (biteTime > 0) { - biteTime--; - } + prevBiteTime = biteTime; + if (biteTime > 0) { + biteTime--; + } - float targetSize = getScaleFactor(); - boolean sizeChanging = prevSize != currentSize; - prevSize = currentSize; - tickGrowth(targetSize, sizeChanging); + float targetSize = getScaleFactor(); + boolean sizeChanging = prevSize != currentSize; + prevSize = currentSize; + tickGrowth(targetSize, sizeChanging); - if (!hasPositionTarget() && homePos.isPresent()) { - setPositionTarget(homePos.get(), (int)getAreaRadius()); + if (!hasPositionTarget() && homePos.isPresent()) { + setPositionTarget(homePos.get(), (int)getAreaRadius()); + } } super.tick();