made the aura detector less accurate in favor of intuitive behavior

This commit is contained in:
Ellpeck 2018-12-04 21:31:22 +01:00
parent f8f44615cc
commit cd5b98d68f
2 changed files with 10 additions and 7 deletions

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.MathHelper;
import org.apache.commons.lang3.mutable.MutableFloat;
public class TileEntityAuraDetector extends TileEntityImpl implements ITickable {
@ -11,8 +12,12 @@ public class TileEntityAuraDetector extends TileEntityImpl implements ITickable
@Override
public void update() {
if (!this.world.isRemote && this.world.getTotalWorldTime() % 80 == 0) {
int amount = IAuraChunk.getAuraInArea(this.world, this.pos, 30);
int power = MathHelper.clamp(MathHelper.ceil(amount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
MutableFloat totalAmount = new MutableFloat(IAuraChunk.DEFAULT_AURA);
IAuraChunk.getSpotsInArea(this.world, this.pos, 25, (pos, spot) -> {
float percentage = 1F - (float) this.pos.getDistance(pos.getX(), pos.getY(), pos.getZ()) / 25F;
totalAmount.add(spot * percentage);
});
int power = MathHelper.clamp(MathHelper.ceil(totalAmount.intValue() / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
if (this.redstonePower != power) {
this.redstonePower = power;
this.world.updateComparatorOutputLevel(this.pos, this.getBlockType());

View file

@ -17,16 +17,14 @@ public class BalanceEffect implements IDrainSpotEffect {
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (spot < 1000)
return;
int radius = Math.min(80, spot / 40);
int radius = Math.min(80, spot / 50);
if (radius <= 0)
return;
BlockPos lowestPos = IAuraChunk.getLowestSpot(world, pos, radius, null);
if (lowestPos == null)
return;
IAuraChunk lowestChunk = IAuraChunk.getAuraChunk(world, lowestPos);
int toTransfer = Math.min(spot / 10, -lowestChunk.getDrainSpot(lowestPos));
int stored = auraChunk.drainAura(pos, toTransfer);
lowestChunk.storeAura(lowestPos, stored);
int stored = IAuraChunk.getAuraChunk(world, lowestPos).storeAura(lowestPos, spot / 10);
auraChunk.drainAura(pos, stored);
}
@Override