Fixed crash when summoning sombra with commands when on peaceful mode. Closes #187

This commit is contained in:
Sollace 2023-09-13 14:07:39 +01:00
parent b7487e9901
commit 7187ad61ee
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -226,28 +226,30 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
setPersistent();
Optional<BlockPos> 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();