mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
added a nice looking aura effect
This commit is contained in:
parent
95e7f398e3
commit
37bd687d1f
5 changed files with 88 additions and 4 deletions
|
@ -60,13 +60,13 @@ public final class ModConfig {
|
|||
@Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
||||
@RangeDouble(min = 0, max = 1)
|
||||
public double particleAmount = 1;
|
||||
|
||||
@Comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
|
||||
public boolean respectVanillaParticleSettings = true;
|
||||
@Comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
|
||||
public double excessParticleAmount = 1;
|
||||
|
||||
@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
|
||||
public boolean debugText = true;
|
||||
|
||||
@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
|
||||
public boolean debugWorld = false;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,8 @@ public class AuraChunk implements IAuraChunk {
|
|||
return 0;
|
||||
MutableInt spot = this.getActualDrainSpot(pos, true);
|
||||
int curr = spot.intValue();
|
||||
if (curr < 0 && curr - amount > 0) { // Underflow protection
|
||||
if (curr < 0 && curr - amount > 0) // Underflow protection
|
||||
return this.drainAura(pos.up(), amount, aimForZero, simulate);
|
||||
}
|
||||
if (aimForZero) {
|
||||
if (curr > 0 && curr - amount < 0)
|
||||
amount = curr;
|
||||
|
|
|
@ -14,6 +14,7 @@ public final class DrainSpotEffects {
|
|||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(SpreadEffect.NAME, SpreadEffect::new);
|
||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(CacheRechargeEffect.NAME, CacheRechargeEffect::new);
|
||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(AnimalEffect.NAME, AnimalEffect::new);
|
||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(NiceLookingEffect.NAME, NiceLookingEffect::new);
|
||||
|
||||
NaturesAuraAPI.EFFECT_POWDERS.put(PlantBoostEffect.NAME, 0xc2f442);
|
||||
NaturesAuraAPI.EFFECT_POWDERS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package de.ellpeck.naturesaura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
public class NiceLookingEffect implements IDrainSpotEffect {
|
||||
|
||||
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "nice_looking");
|
||||
|
||||
@Override
|
||||
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (spot < 0)
|
||||
return;
|
||||
MutableInt aura = new MutableInt();
|
||||
MutableInt spots = new MutableInt();
|
||||
IAuraChunk.getSpotsInArea(world, pos, 35, (otherSpot, otherAmount) -> {
|
||||
spots.add(1);
|
||||
aura.add(otherAmount);
|
||||
});
|
||||
int excess = aura.intValue();
|
||||
if (excess <= 0)
|
||||
return;
|
||||
int amount = Math.min(50, excess / 400);
|
||||
if (amount < 2)
|
||||
return;
|
||||
if (spots.intValue() > 1)
|
||||
amount = Math.max(2, amount / (spots.intValue() - 1));
|
||||
for (int i = amount + world.rand.nextInt(amount / 2); i > 1; i--) {
|
||||
if (world.rand.nextFloat() >= 0.25F)
|
||||
continue;
|
||||
int x = pos.getX() + world.rand.nextInt(32) - 16;
|
||||
int z = pos.getZ() + world.rand.nextInt(32) - 16;
|
||||
BlockPos plantPos = new BlockPos(x, world.getHeight(x, z) - 1, z);
|
||||
if (!world.isBlockLoaded(plantPos))
|
||||
continue;
|
||||
IBlockState state = world.getBlockState(plantPos);
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof IGrowable || block instanceof IPlantable || block.isLeaves(state, world, plantPos))
|
||||
PacketHandler.sendToAllAround(world, plantPos, 32,
|
||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 21, excess));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||
return type == NaturesAuraAPI.TYPE_OVERWORLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||
|
@ -337,6 +338,22 @@ public class PacketParticles implements IMessage {
|
|||
return true;
|
||||
});
|
||||
break;
|
||||
case 21: // Nice looking effect
|
||||
int excess = message.data[0];
|
||||
double setting = ModConfig.client.excessParticleAmount;
|
||||
if (setting >= 1 || world.rand.nextFloat() <= setting)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
message.posX + world.rand.nextFloat(),
|
||||
message.posY + world.rand.nextFloat(),
|
||||
message.posZ + world.rand.nextFloat(),
|
||||
world.rand.nextGaussian() * 0.01F,
|
||||
world.rand.nextFloat() * 0.025F,
|
||||
world.rand.nextGaussian() * 0.01F,
|
||||
BiomeColorHelper.getFoliageColorAtPos(world, new BlockPos(message.posX, message.posY, message.posZ)),
|
||||
Math.min(2F, 0.5F + world.rand.nextFloat() * (excess / 1000F)),
|
||||
Math.min(300, 100 + world.rand.nextInt(excess / 30 + 1)),
|
||||
0F, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue