Compare commits

..

2 commits

Author SHA1 Message Date
Ell
791c6ada5e fixed effect inhibitor crash
closes #328
2023-09-25 13:42:06 +02:00
Ell
41214e7b2f fixed a rare race condition (?) when iterating block entities
closes #329
2023-09-25 13:35:42 +02:00
2 changed files with 7 additions and 4 deletions

View file

@ -67,13 +67,15 @@ public final class Helper {
var chunk = Helper.getLoadedChunk(level, x, z);
if (chunk != null) {
for (var tilePos : chunk.getBlockEntitiesPos()) {
if (tilePos.distSqr(pos) <= radius * radius)
if (consumer.apply(chunk.getBlockEntity(tilePos)))
if (tilePos.distSqr(pos) <= radius * radius) {
var tile = chunk.getBlockEntity(tilePos);
if (tile != null && consumer.apply(tile))
return true;
}
}
}
}
}
return false;
}

View file

@ -68,7 +68,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
@Override
protected void defineSynchedData() {
this.entityData.define(EntityEffectInhibitor.INHIBITED_EFFECT, null);
this.entityData.define(EntityEffectInhibitor.INHIBITED_EFFECT, "");
this.entityData.define(EntityEffectInhibitor.COLOR, 0);
this.entityData.define(EntityEffectInhibitor.AMOUNT, 0);
}
@ -168,7 +168,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
}
public void setInhibitedEffect(ResourceLocation effect) {
this.entityData.set(EntityEffectInhibitor.INHIBITED_EFFECT, effect != null ? effect.toString() : null);
this.entityData.set(EntityEffectInhibitor.INHIBITED_EFFECT, effect != null ? effect.toString() : "");
}
public int getColor() {
@ -212,4 +212,5 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
this.powderListDirty = false;
this.lastEffect = inhibitedEffect;
}
}