From 69e07e25a55e9afa9a3c490880ae4e8b04cd8af6 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 24 Nov 2018 17:32:39 +0100 Subject: [PATCH] add a simulate parameter to IAuraChunk draining/storing for convenience --- .../api/aura/chunk/IAuraChunk.java | 20 +++++++++---------- .../ellpeck/naturesaura/chunk/AuraChunk.java | 20 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java index 2e2a32bd..9439c452 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java @@ -132,13 +132,13 @@ public interface IAuraChunk extends ICapabilityProvider, INBTSerializable 0 && curr - amount < 0) amount = curr; } - spot.subtract(amount); - this.markDirty(); + if (!simulate) { + spot.subtract(amount); + this.markDirty(); + } return amount; } @Override public int drainAura(BlockPos pos, int amount) { - return this.drainAura(pos, amount, false); + return this.drainAura(pos, amount, false, false); } @Override - public int storeAura(BlockPos pos, int amount, boolean aimForZero) { + public int storeAura(BlockPos pos, int amount, boolean aimForZero, boolean simulate) { if (amount <= 0) return 0; MutableInt spot = this.getDrainSpot(pos); @@ -83,14 +85,16 @@ public class AuraChunk implements IAuraChunk { amount = -curr; } } - spot.add(amount); - this.markDirty(); + if (!simulate) { + spot.add(amount); + this.markDirty(); + } return amount; } @Override public int storeAura(BlockPos pos, int amount) { - return this.storeAura(pos, amount, true); + return this.storeAura(pos, amount, true, false); } @Override