slightly increase performance by reducing the activity of some effects

This commit is contained in:
Ell 2021-01-30 17:21:41 +01:00
parent ba6c274842
commit 8417523e31
3 changed files with 34 additions and 30 deletions

View file

@ -66,6 +66,8 @@ public class AnimalEffect implements IDrainSpotEffect {
@Override @Override
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 (world.getGameTime() % 200 != 0)
return;
if (!this.calcValues(world, pos, spot)) if (!this.calcValues(world, pos, spot))
return; return;
@ -73,7 +75,6 @@ public class AnimalEffect implements IDrainSpotEffect {
if (animals.size() >= 200) if (animals.size() >= 200)
return; return;
if (world.getGameTime() % 200 == 0) {
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, this.bb); List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, this.bb);
for (ItemEntity item : items) { for (ItemEntity item : items) {
if (!item.isAlive()) if (!item.isAlive())
@ -104,9 +105,8 @@ public class AnimalEffect implements IDrainSpotEffect {
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos); BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos);
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 2000); IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 2000);
} }
}
if (world.rand.nextInt(200) <= this.chance) { if (world.rand.nextInt(20) <= this.chance) {
if (animals.size() < 2) if (animals.size() < 2)
return; return;
AnimalEntity first = animals.get(world.rand.nextInt(animals.size())); AnimalEntity first = animals.get(world.rand.nextInt(animals.size()));

View file

@ -18,6 +18,8 @@ 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 < 100000) if (spot < 100000)
return; return;
if (world.getGameTime() % 200 != 0)
return;
int searchRadius = Math.min(45, spot / 10000); int searchRadius = Math.min(45, spot / 10000);
MutableInt positiveAura = new MutableInt(); MutableInt positiveAura = new MutableInt();
IAuraChunk.getSpotsInArea(world, pos, searchRadius, (otherPos, otherSpot) -> { IAuraChunk.getSpotsInArea(world, pos, searchRadius, (otherPos, otherSpot) -> {
@ -28,7 +30,7 @@ public class BalanceEffect implements IDrainSpotEffect {
BlockPos lowestPos = IAuraChunk.getLowestSpot(world, pos, radius, null); BlockPos lowestPos = IAuraChunk.getLowestSpot(world, pos, radius, null);
if (lowestPos == null) if (lowestPos == null)
return; return;
int stored = IAuraChunk.getAuraChunk(world, lowestPos).storeAura(lowestPos, spot / 500); int stored = IAuraChunk.getAuraChunk(world, lowestPos).storeAura(lowestPos, spot / 50);
auraChunk.drainAura(pos, stored); auraChunk.drainAura(pos, stored);
} }

View file

@ -59,6 +59,8 @@ public class NetherGrassEffect implements IDrainSpotEffect {
@Override @Override
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 (world.getGameTime() % 40 != 0)
return;
if (!this.calcValues(world, pos, spot)) if (!this.calcValues(world, pos, spot))
return; return;
for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) { for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) {