use AspectList.remove instead of AspectList.reduce to fix "sometimes drainer doesn't work with essentia import bus" (#56)

This commit is contained in:
SST-03 authored and GitHub committed 2026-02-02 20:38:45 +01:00
1 parent f881470241
commit 9ce571f464
1 file changed
+9 -9
@@ -159,7 +159,7 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
if (this.essentia.getAmount(tag) >= amount) {
this.essentia.reduce(tag, amount);
this.essentia.remove(tag, amount);
return true;
}
return false;
@@ -177,7 +177,7 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
}
if (hasIt) {
for (Aspect next : ot.aspects.keySet()) {
essentia.reduce(next, ot.getAmount(next));
essentia.remove(next, ot.getAmount(next));
}
return true;
}
@@ -224,13 +224,10 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
if (!this.worldObj.isRemote) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
if (amount > this.essentia.getAmount(aspect)) {
int total = this.essentia.getAmount(aspect);
this.essentia.reduce(aspect, total);
return total;
}
this.essentia.reduce(aspect, amount);
return amount;
int total = this.essentia.getAmount(aspect);
this.essentia.remove(aspect, amount); // if amount >= total then it will also remove aspect.
return Math.min(amount, total);
}
return 0;
}
@@ -289,6 +286,9 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
this.essentia.readFromNBT(compound);
for (Aspect aspect : this.essentia.getAspects()) {
if (this.essentia.getAmount(aspect) <= 0) this.essentia.remove(aspect);
}
if (this.essentia.visSize() > this.maxAmount) {
this.essentia = new AspectList();
}