mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 13:57:59 +01:00
Fixed crash with spellcast entities accessing lighting buffers when they mustn't (TODO: make this better somehow)
This commit is contained in:
parent
59db55aa63
commit
7ad82f0bb2
1 changed files with 12 additions and 6 deletions
|
@ -4,6 +4,7 @@ import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Levelled;
|
import com.minelittlepony.unicopia.ability.magic.Levelled;
|
||||||
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
|
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
|
||||||
|
@ -84,14 +85,20 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
BlockPos currentPos = getBlockPos();
|
BlockPos currentPos = getBlockPos();
|
||||||
|
|
||||||
|
if (world.isChunkLoaded(currentPos)) {
|
||||||
|
try {
|
||||||
world.getLightingProvider().addLightSource(currentPos, 11);
|
world.getLightingProvider().addLightSource(currentPos, 11);
|
||||||
|
|
||||||
if (lastPos != null && !currentPos.equals(lastPos)) {
|
if (lastPos != null && !currentPos.equals(lastPos)) {
|
||||||
world.getLightingProvider().checkBlock(lastPos);
|
world.getLightingProvider().checkBlock(lastPos);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Unicopia.LOGGER.error("Error updating lighting", e);
|
||||||
|
}
|
||||||
|
|
||||||
lastPos = currentPos;
|
lastPos = currentPos;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
LivingEntity master = getMaster();
|
LivingEntity master = getMaster();
|
||||||
|
|
||||||
if (master == null || master.isRemoved()) {
|
if (master == null || master.isRemoved()) {
|
||||||
|
@ -170,7 +177,6 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
dataTracker.get(SPELL).ifPresent(spellId -> {
|
dataTracker.get(SPELL).ifPresent(spellId -> {
|
||||||
tag.putUuid("spellId", spellId);
|
tag.putUuid("spellId", spellId);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue