mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
add a simulate parameter to IAuraChunk draining/storing for convenience
This commit is contained in:
parent
f6420d2c8e
commit
69e07e25a5
2 changed files with 22 additions and 18 deletions
|
@ -132,13 +132,13 @@ public interface IAuraChunk extends ICapabilityProvider, INBTSerializable<NBTTag
|
||||||
* @return The amount of Aura drained. Will only be different from the
|
* @return The amount of Aura drained. Will only be different from the
|
||||||
* supplied amount if stopAtZero is true
|
* supplied amount if stopAtZero is true
|
||||||
*/
|
*/
|
||||||
int drainAura(BlockPos pos, int amount, boolean aimForZero);
|
int drainAura(BlockPos pos, int amount, boolean aimForZero, boolean simulate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience version of {@link #drainAura(BlockPos, int, boolean)} with
|
* Convenience version of {@link #drainAura(BlockPos, int, boolean,
|
||||||
* aimForZero set to false, as this is the most likely behavior you will
|
* boolean)} with aimForZero and simulate set to false, as this is the most
|
||||||
* want. Notice that {@link #storeAura(BlockPos, int)} has aimForZero set to
|
* likely behavior you will want. Notice that {@link #storeAura(BlockPos,
|
||||||
* true.
|
* int)} has aimForZero set to true.
|
||||||
*/
|
*/
|
||||||
int drainAura(BlockPos pos, int amount);
|
int drainAura(BlockPos pos, int amount);
|
||||||
|
|
||||||
|
@ -155,13 +155,13 @@ public interface IAuraChunk extends ICapabilityProvider, INBTSerializable<NBTTag
|
||||||
* @return The amount of Aura stored. Will only be different from the
|
* @return The amount of Aura stored. Will only be different from the
|
||||||
* supplied amount if stopAtZero is true
|
* supplied amount if stopAtZero is true
|
||||||
*/
|
*/
|
||||||
int storeAura(BlockPos pos, int amount, boolean aimForZero);
|
int storeAura(BlockPos pos, int amount, boolean aimForZero, boolean simulate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience version of {@link #storeAura(BlockPos, int, boolean)} with
|
* Convenience version of {@link #storeAura(BlockPos, int, boolean,
|
||||||
* aimForZero set to true, as this is the most likely behavior you will
|
* boolean)} with aimForZero set to true and simulate set to false, as this
|
||||||
* want. Notice that {@link #drainAura(BlockPos, int)} has aimForZero set to
|
* is the most likely behavior you will want. Notice that {@link
|
||||||
* false.
|
* #drainAura(BlockPos, int)} has aimForZero set to false.
|
||||||
*/
|
*/
|
||||||
int storeAura(BlockPos pos, int amount);
|
int storeAura(BlockPos pos, int amount);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class AuraChunk implements IAuraChunk {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int drainAura(BlockPos pos, int amount, boolean aimForZero) {
|
public int drainAura(BlockPos pos, int amount, boolean aimForZero, boolean simulate) {
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
MutableInt spot = this.getDrainSpot(pos);
|
MutableInt spot = this.getDrainSpot(pos);
|
||||||
|
@ -62,18 +62,20 @@ public class AuraChunk implements IAuraChunk {
|
||||||
if (curr > 0 && curr - amount < 0)
|
if (curr > 0 && curr - amount < 0)
|
||||||
amount = curr;
|
amount = curr;
|
||||||
}
|
}
|
||||||
spot.subtract(amount);
|
if (!simulate) {
|
||||||
this.markDirty();
|
spot.subtract(amount);
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int drainAura(BlockPos pos, int amount) {
|
public int drainAura(BlockPos pos, int amount) {
|
||||||
return this.drainAura(pos, amount, false);
|
return this.drainAura(pos, amount, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int storeAura(BlockPos pos, int amount, boolean aimForZero) {
|
public int storeAura(BlockPos pos, int amount, boolean aimForZero, boolean simulate) {
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
MutableInt spot = this.getDrainSpot(pos);
|
MutableInt spot = this.getDrainSpot(pos);
|
||||||
|
@ -83,14 +85,16 @@ public class AuraChunk implements IAuraChunk {
|
||||||
amount = -curr;
|
amount = -curr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spot.add(amount);
|
if (!simulate) {
|
||||||
this.markDirty();
|
spot.add(amount);
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int storeAura(BlockPos pos, int amount) {
|
public int storeAura(BlockPos pos, int amount) {
|
||||||
return this.storeAura(pos, amount, true);
|
return this.storeAura(pos, amount, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue