mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-23 04:08:34 +01:00
fixed effects happening more often the more spots there were, regardless of the amount of aura
This commit is contained in:
parent
8fba5c7f90
commit
c8211cd3ba
9 changed files with 36 additions and 7 deletions
|
@ -117,6 +117,13 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
world.profiler.endSection();
|
world.profiler.endSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSpotAmountInArea(World world, BlockPos pos, int radius) {
|
||||||
|
MutableInt result = new MutableInt();
|
||||||
|
this.getAuraSpotsInArea(world, pos, radius, (blockpos, drainSpot) -> result.increment());
|
||||||
|
return result.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAuraInArea(World world, BlockPos pos, int radius) {
|
public int getAuraInArea(World world, BlockPos pos, int radius) {
|
||||||
MutableInt result = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
MutableInt result = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||||
|
|
|
@ -267,6 +267,11 @@ public final class NaturesAuraAPI {
|
||||||
*/
|
*/
|
||||||
void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer);
|
void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IAuraChunk#getSpotAmountInArea(World, BlockPos, int)
|
||||||
|
*/
|
||||||
|
int getSpotAmountInArea(World world, BlockPos pos, int radius);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IAuraChunk#getAuraInArea(World, BlockPos, int)
|
* @see IAuraChunk#getAuraInArea(World, BlockPos, int)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -57,6 +57,19 @@ public interface IAuraChunk extends ICapabilityProvider, INBTSerializable<NBTTag
|
||||||
NaturesAuraAPI.instance().getAuraSpotsInArea(world, pos, radius, consumer);
|
NaturesAuraAPI.instance().getAuraSpotsInArea(world, pos, radius, consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method that adds up the amount of aura spots from {@link
|
||||||
|
* #getSpotsInArea(World, BlockPos, int, BiConsumer)} and returns it.
|
||||||
|
*
|
||||||
|
* @param world The world
|
||||||
|
* @param pos The center position
|
||||||
|
* @param radius The radius around the center to search for spots in
|
||||||
|
* @return The amount of spots found in the area
|
||||||
|
*/
|
||||||
|
static int getSpotAmountInArea(World world, BlockPos pos, int radius) {
|
||||||
|
return NaturesAuraAPI.instance().getSpotAmountInArea(world, pos, radius);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method that adds up all of the aura from each drain spot from
|
* Convenience method that adds up all of the aura from each drain spot from
|
||||||
* {@link #getSpotsInArea(World, BlockPos, int, BiConsumer)} and
|
* {@link #getSpotsInArea(World, BlockPos, int, BiConsumer)} and
|
||||||
|
|
|
@ -46,6 +46,11 @@ public class StubHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSpotAmountInArea(World world, BlockPos pos, int radius) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAuraInArea(World world, BlockPos pos, int radius) {
|
public int getAuraInArea(World world, BlockPos pos, int radius) {
|
||||||
return IAuraChunk.DEFAULT_AURA;
|
return IAuraChunk.DEFAULT_AURA;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
int aura = IAuraChunk.getAuraInArea(world, pos, 30);
|
int aura = IAuraChunk.getAuraInArea(world, pos, 30);
|
||||||
if (aura < 1500000)
|
if (aura < 1500000)
|
||||||
return false;
|
return false;
|
||||||
this.chance = Math.min(50, Math.abs(aura) / 500000);
|
this.chance = Math.min(50, Math.abs(aura) / 500000 / IAuraChunk.getSpotAmountInArea(world, pos, 30));
|
||||||
if (this.chance <= 0)
|
if (this.chance <= 0)
|
||||||
return false;
|
return false;
|
||||||
int dist = MathHelper.clamp(Math.abs(aura) / 150000, 5, 35);
|
int dist = MathHelper.clamp(Math.abs(aura) / 150000, 5, 35);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
|
||||||
return false;
|
return false;
|
||||||
int dist = MathHelper.clamp(aura / 3500, 3, 15);
|
int dist = MathHelper.clamp(aura / 3500, 3, 15);
|
||||||
this.bb = new AxisAlignedBB(pos).grow(dist);
|
this.bb = new AxisAlignedBB(pos).grow(dist);
|
||||||
this.amount = aura / 250000 - 2;
|
this.amount = aura / 250000 / IAuraChunk.getSpotAmountInArea(world, pos, 20) - 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ public class ExplosionEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "explosions");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "explosions");
|
||||||
|
|
||||||
private int chance;
|
|
||||||
private float strength;
|
private float strength;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
|
||||||
|
@ -28,8 +27,8 @@ public class ExplosionEffect implements IDrainSpotEffect {
|
||||||
int aura = IAuraChunk.getAuraInArea(world, pos, 85);
|
int aura = IAuraChunk.getAuraInArea(world, pos, 85);
|
||||||
if (aura > -5000000)
|
if (aura > -5000000)
|
||||||
return false;
|
return false;
|
||||||
this.chance = 140 - Math.abs(aura) / 200000;
|
int chance = 140 - Math.abs(aura) / 200000;
|
||||||
if (this.chance > 1 && world.rand.nextInt(this.chance) != 0)
|
if (chance > 1 && world.rand.nextInt(chance) != 0)
|
||||||
return false;
|
return false;
|
||||||
this.strength = Math.min(Math.abs(aura) / 5000000F, 5F);
|
this.strength = Math.min(Math.abs(aura) / 5000000F, 5F);
|
||||||
if (this.strength <= 0)
|
if (this.strength <= 0)
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
||||||
if (spot < 0) {
|
if (spot < 0) {
|
||||||
int aura = IAuraChunk.getAuraInArea(world, pos, 50);
|
int aura = IAuraChunk.getAuraInArea(world, pos, 50);
|
||||||
if (aura < 0) {
|
if (aura < 0) {
|
||||||
this.amount = Math.min(300, Math.abs(aura) / 100000);
|
this.amount = Math.min(300, Math.abs(aura) / 100000 / IAuraChunk.getSpotAmountInArea(world, pos, 50));
|
||||||
if (this.amount > 1) {
|
if (this.amount > 1) {
|
||||||
this.dist = MathHelper.clamp(Math.abs(aura) / 75000, 5, 75);
|
this.dist = MathHelper.clamp(Math.abs(aura) / 75000, 5, 75);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
int aura = IAuraChunk.getAuraInArea(world, pos, 30);
|
int aura = IAuraChunk.getAuraInArea(world, pos, 30);
|
||||||
if (aura < 1500000)
|
if (aura < 1500000)
|
||||||
return false;
|
return false;
|
||||||
this.amount = Math.min(45, Math.abs(aura) / 100000);
|
this.amount = Math.min(45, Math.abs(aura) / 100000 / IAuraChunk.getSpotAmountInArea(world, pos, 30));
|
||||||
if (this.amount <= 1)
|
if (this.amount <= 1)
|
||||||
return false;
|
return false;
|
||||||
this.dist = MathHelper.clamp(Math.abs(aura) / 150000, 5, 35);
|
this.dist = MathHelper.clamp(Math.abs(aura) / 150000, 5, 35);
|
||||||
|
|
Loading…
Reference in a new issue