make the nice looking effect only appear on natural blocks

This commit is contained in:
Ellpeck 2019-01-28 17:12:50 +01:00
parent d3ac776d6d
commit 13da4fc833

View file

@ -17,6 +17,7 @@ import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.particles.ParticleHandler; import de.ellpeck.naturesaura.particles.ParticleHandler;
import de.ellpeck.naturesaura.particles.ParticleMagic; import de.ellpeck.naturesaura.particles.ParticleMagic;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
@ -37,6 +38,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.energy.EnergyStorage; import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
@ -113,23 +115,26 @@ public class ClientEvents {
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
int x = MathHelper.floor(mc.player.posX) + mc.world.rand.nextInt(64) - 32; 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; int z = MathHelper.floor(mc.player.posZ) + mc.world.rand.nextInt(64) - 32;
BlockPos pos = new BlockPos(x, mc.world.getHeight(x, z), z); BlockPos pos = new BlockPos(x, mc.world.getHeight(x, z) - 1, z);
IBlockState state = mc.world.getBlockState(pos);
int excess = IAuraChunk.triangulateAuraInArea(mc.world, pos, 45) - IAuraChunk.DEFAULT_AURA; Block block = state.getBlock();
if (excess > 0) { if (block instanceof IGrowable || block instanceof IPlantable || block.isLeaves(state, mc.world, pos)) {
int chance = Math.max(10, 50 - excess / 250); int excess = IAuraChunk.triangulateAuraInArea(mc.world, pos, 45) - IAuraChunk.DEFAULT_AURA;
if (mc.world.rand.nextInt(chance) <= 0) if (excess > 0) {
NaturesAuraAPI.instance().spawnMagicParticle( int chance = Math.max(10, 50 - excess / 250);
pos.getX() + mc.world.rand.nextFloat(), if (mc.world.rand.nextInt(chance) <= 0)
pos.getY() - 0.5F, NaturesAuraAPI.instance().spawnMagicParticle(
pos.getZ() + mc.world.rand.nextFloat(), pos.getX() + mc.world.rand.nextFloat(),
mc.world.rand.nextGaussian() * 0.01F, pos.getY() + 0.5F,
mc.world.rand.nextFloat() * 0.025F, pos.getZ() + mc.world.rand.nextFloat(),
mc.world.rand.nextGaussian() * 0.01F, mc.world.rand.nextGaussian() * 0.01F,
BiomeColorHelper.getFoliageColorAtPos(mc.world, pos), mc.world.rand.nextFloat() * 0.025F,
Math.min(2F, 1F + mc.world.rand.nextFloat() * (excess / 300F)), mc.world.rand.nextGaussian() * 0.01F,
Math.min(300, 100 + mc.world.rand.nextInt(excess / 30 + 1)), BiomeColorHelper.getFoliageColorAtPos(mc.world, pos),
0F, false, true); 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.endSection();