make over- and underflow create another spot

This commit is contained in:
Ellpeck 2018-12-03 14:40:53 +01:00
parent 5fcd096a99
commit 656a76980b

View file

@ -61,8 +61,9 @@ public class AuraChunk implements IAuraChunk {
return 0; return 0;
MutableInt spot = this.getActualDrainSpot(pos, true); MutableInt spot = this.getActualDrainSpot(pos, true);
int curr = spot.intValue(); int curr = spot.intValue();
if (curr < 0 && curr - amount > 0) // Underflow protection if (curr < 0 && curr - amount > 0) { // Underflow protection
return amount; return this.drainAura(pos.up(), amount, aimForZero, simulate);
}
if (aimForZero) { if (aimForZero) {
if (curr > 0 && curr - amount < 0) if (curr > 0 && curr - amount < 0)
amount = curr; amount = curr;
@ -88,7 +89,7 @@ public class AuraChunk implements IAuraChunk {
MutableInt spot = this.getActualDrainSpot(pos, true); MutableInt spot = this.getActualDrainSpot(pos, true);
int curr = spot.intValue(); int curr = spot.intValue();
if (curr > 0 && curr + amount < 0) // Overflow protection if (curr > 0 && curr + amount < 0) // Overflow protection
return amount; return this.storeAura(pos.up(), amount, aimForZero, simulate);
if (aimForZero) { if (aimForZero) {
if (curr < 0 && curr + amount > 0) { if (curr < 0 && curr + amount > 0) {
amount = -curr; amount = -curr;