mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
make the nice looking effect ACTUALLY look nice
This commit is contained in:
parent
e713948545
commit
d3ac776d6d
4 changed files with 34 additions and 90 deletions
|
@ -14,7 +14,6 @@ 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);
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeColorHelper;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
|
@ -99,18 +100,45 @@ public class ClientEvents {
|
|||
public void onClientTick(ClientTickEvent event) {
|
||||
if (event.phase == Phase.END) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":updateParticles");
|
||||
if (!mc.isGamePaused())
|
||||
ParticleHandler.updateParticles();
|
||||
mc.profiler.endSection();
|
||||
|
||||
if (mc.world == null) {
|
||||
ParticleHandler.clearParticles();
|
||||
if (!ItemRangeVisualizer.VISUALIZED_BLOCKS.isEmpty())
|
||||
ItemRangeVisualizer.VISUALIZED_BLOCKS.clear();
|
||||
if (!ItemRangeVisualizer.VISUALIZED_ENTITIES.isEmpty())
|
||||
ItemRangeVisualizer.VISUALIZED_ENTITIES.clear();
|
||||
} else {
|
||||
if (mc.world.getTotalWorldTime() % 20 == 0) {
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":spawnExcessParticles");
|
||||
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
int x = MathHelper.floor(mc.player.posX) + mc.world.rand.nextInt(64) - 32;
|
||||
int z = MathHelper.floor(mc.player.posZ) + mc.world.rand.nextInt(64) - 32;
|
||||
BlockPos pos = new BlockPos(x, mc.world.getHeight(x, z), z);
|
||||
|
||||
int excess = IAuraChunk.triangulateAuraInArea(mc.world, pos, 45) - IAuraChunk.DEFAULT_AURA;
|
||||
if (excess > 0) {
|
||||
int chance = Math.max(10, 50 - excess / 250);
|
||||
if (mc.world.rand.nextInt(chance) <= 0)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
pos.getX() + mc.world.rand.nextFloat(),
|
||||
pos.getY() - 0.5F,
|
||||
pos.getZ() + mc.world.rand.nextFloat(),
|
||||
mc.world.rand.nextGaussian() * 0.01F,
|
||||
mc.world.rand.nextFloat() * 0.025F,
|
||||
mc.world.rand.nextGaussian() * 0.01F,
|
||||
BiomeColorHelper.getFoliageColorAtPos(mc.world, pos),
|
||||
Math.min(2F, 1F + mc.world.rand.nextFloat() * (excess / 300F)),
|
||||
Math.min(300, 100 + mc.world.rand.nextInt(excess / 30 + 1)),
|
||||
0F, false, true);
|
||||
}
|
||||
}
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":updateParticles");
|
||||
if (!mc.isGamePaused())
|
||||
ParticleHandler.updateParticles();
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,22 +338,6 @@ 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