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 de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import org.apache.commons.lang3.mutable.MutableFloat;
public class TileEntityAuraDetector extends TileEntityImpl implements ITickable { public class TileEntityAuraDetector extends TileEntityImpl implements ITickable {
@ -11,8 +12,12 @@ public class TileEntityAuraDetector extends TileEntityImpl implements ITickable
@Override @Override
public void update() { public void update() {
if (!this.world.isRemote && this.world.getTotalWorldTime() % 80 == 0) { if (!this.world.isRemote && this.world.getTotalWorldTime() % 80 == 0) {
int amount = IAuraChunk.getAuraInArea(this.world, this.pos, 30); MutableFloat totalAmount = new MutableFloat(IAuraChunk.DEFAULT_AURA);
int power = MathHelper.clamp(MathHelper.ceil(amount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15); 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) { if (this.redstonePower != power) {
this.redstonePower = power; this.redstonePower = power;
this.world.updateComparatorOutputLevel(this.pos, this.getBlockType()); 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) { public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (spot < 1000) if (spot < 1000)
return; return;
int radius = Math.min(80, spot / 40); int radius = Math.min(80, spot / 50);
if (radius <= 0) if (radius <= 0)
return; return;
BlockPos lowestPos = IAuraChunk.getLowestSpot(world, pos, radius, null); BlockPos lowestPos = IAuraChunk.getLowestSpot(world, pos, radius, null);
if (lowestPos == null) if (lowestPos == null)
return; return;
IAuraChunk lowestChunk = IAuraChunk.getAuraChunk(world, lowestPos); int stored = IAuraChunk.getAuraChunk(world, lowestPos).storeAura(lowestPos, spot / 10);
int toTransfer = Math.min(spot / 10, -lowestChunk.getDrainSpot(lowestPos)); auraChunk.drainAura(pos, stored);
int stored = auraChunk.drainAura(pos, toTransfer);
lowestChunk.storeAura(lowestPos, stored);
} }
@Override @Override