Fixed crash with spellcast entities accessing lighting buffers when they mustn't (TODO: make this better somehow)

This commit is contained in:
Sollace 2021-12-26 10:48:01 +02:00
parent 59db55aa63
commit 7ad82f0bb2

View file

@ -4,6 +4,7 @@ import java.util.Optional;
import java.util.UUID;
import com.minelittlepony.unicopia.Affinity;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Levelled;
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
@ -84,14 +85,20 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
if (world.isClient) {
BlockPos currentPos = getBlockPos();
if (world.isChunkLoaded(currentPos)) {
try {
world.getLightingProvider().addLightSource(currentPos, 11);
if (lastPos != null && !currentPos.equals(lastPos)) {
world.getLightingProvider().checkBlock(lastPos);
}
} catch (Exception e) {
Unicopia.LOGGER.error("Error updating lighting", e);
}
lastPos = currentPos;
}
}
LivingEntity master = getMaster();
if (master == null || master.isRemoved()) {
@ -170,7 +177,6 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
dataTracker.get(SPELL).ifPresent(spellId -> {
tag.putUuid("spellId", spellId);
});
}
@Override