fixed effect powder being unable to save correctly

closes #267
This commit is contained in:
Ell 2022-09-15 15:41:48 +02:00
parent d334272467
commit a24d73dc77

View file

@ -62,8 +62,8 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
@Override @Override
public void onRemovedFromWorld() { public void onRemovedFromWorld() {
super.onRemovedFromWorld(); super.onRemovedFromWorld();
this.setInhibitedEffect(null); // we pass a null effect because we want to remove our effect from the world
this.updatePowderListStatus(); this.updatePowderListStatus(null);
} }
@Override @Override
@ -92,7 +92,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
super.tick(); super.tick();
if (this.powderListDirty) if (this.powderListDirty)
this.updatePowderListStatus(); this.updatePowderListStatus(this.getInhibitedEffect());
if (this.level.isClientSide) { if (this.level.isClientSide) {
if (this.level.getGameTime() % 5 == 0) { if (this.level.getGameTime() % 5 == 0) {
@ -199,18 +199,17 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
return this.getColor(); return this.getColor();
} }
private void updatePowderListStatus() { private void updatePowderListStatus(ResourceLocation inhibitedEffect) {
var powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders; var powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders;
if (this.lastEffect != null) { if (this.lastEffect != null) {
var oldList = powders.get(this.lastEffect); var oldList = powders.get(this.lastEffect);
oldList.removeIf(t -> this.getEyePosition().equals(t.getA())); oldList.removeIf(t -> this.getEyePosition().equals(t.getA()));
} }
var effect = this.getInhibitedEffect(); if (inhibitedEffect != null) {
if (effect != null) { var newList = powders.get(inhibitedEffect);
var newList = powders.get(effect);
newList.add(new Tuple<>(this.getEyePosition(), this.getAmount())); newList.add(new Tuple<>(this.getEyePosition(), this.getAmount()));
} }
this.powderListDirty = false; this.powderListDirty = false;
this.lastEffect = effect; this.lastEffect = inhibitedEffect;
} }
} }