Search in sources :

Example 11 with ParticleManager

use of net.minecraft.client.particle.ParticleManager in project Binnie by ForestryMC.

the class AnalyserFX method onDisplayTick.

@SideOnly(Side.CLIENT)
@Override
public void onDisplayTick(World world, BlockPos pos, Random rand) {
    if (this.getUtil().getProcess().isInProgress()) {
        final ParticleManager effectRenderer = BinnieCore.getBinnieProxy().getMinecraftInstance().effectRenderer;
        effectRenderer.addEffect(new AnalyserParticle(world, pos, rand));
    }
}
Also used : ParticleManager(net.minecraft.client.particle.ParticleManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with ParticleManager

use of net.minecraft.client.particle.ParticleManager in project BetterWithAddons by DaedalusGame.

the class StormHandler method playerTick.

@SubscribeEvent
public void playerTick(TickEvent.PlayerTickEvent tickEvent) {
    EntityPlayer entity = tickEvent.player;
    if (entity == null)
        return;
    World world = entity.world;
    if (world == null || !world.isRemote)
        return;
    if (InteractionBWA.OBVIOUS_STORMS) {
        ParticleManager particleManager = Minecraft.getMinecraft().effectRenderer;
        Random random = world.rand;
        BlockPos pos = entity.getPosition();
        // blocks
        int radius = 16;
        for (int i = 0; i < InteractionBWA.DUST_PARTICLES; i++) {
            BlockPos posGround = pos.add(random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius);
            if (!shouldStorm(world, posGround))
                continue;
            // Constant access whaaaat???
            posGround = world.getHeight(posGround).down();
            IBlockState stateGround = world.getBlockState(posGround);
            Particle particleGround = particleManager.spawnEffectParticle(EnumParticleTypes.BLOCK_DUST.getParticleID(), posGround.getX() + random.nextDouble(), posGround.getY() + 1.2, posGround.getZ() + random.nextDouble(), -0.5 - random.nextDouble() * 0.6, 0.0, 0.0, Block.getStateId(stateGround));
        }
        for (int i = 0; i < InteractionBWA.AIR_PARTICLES; i++) {
            BlockPos posAir = pos.add(random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius);
            if (world.canSeeSky(posAir) && shouldStorm(world, posAir)) {
                Particle particleAir = particleManager.spawnEffectParticle(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), posAir.getX() + random.nextDouble(), posAir.getY() + random.nextDouble(), posAir.getZ() + random.nextDouble(), -0.5 - random.nextDouble() * 0.6, 0.0, 0.0);
                particleAir.setRBGColorF(1.0f, 1.0f, 1.0f);
            }
        }
    }
    if (InteractionBWA.OBVIOUS_SAND_STORMS) {
        float epsilon = 0.001f;
        if (Math.abs(currentDistance - desiredDistance) > epsilon)
            // TODO: We can do better.
            currentDistance += (desiredDistance - currentDistance) * 0.2;
        if (Math.abs(currentDistanceScale - desiredDistanceScale) > epsilon)
            // TODO: We can do better.
            currentDistanceScale += (desiredDistanceScale - currentDistanceScale) * 0.2;
        if (Math.abs(currentRed - desiredRed) > epsilon)
            currentRed += (desiredRed - currentRed) * 0.2;
        if (Math.abs(currentGreen - desiredGreen) > epsilon)
            currentGreen += (desiredGreen - currentGreen) * 0.2;
        if (Math.abs(currentBlue - desiredBlue) > epsilon)
            currentBlue += (desiredBlue - currentBlue) * 0.2;
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) IBlockState(net.minecraft.block.state.IBlockState) Random(java.util.Random) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParticleManager(net.minecraft.client.particle.ParticleManager) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 13 with ParticleManager

use of net.minecraft.client.particle.ParticleManager in project DynamicSurroundings by OreCruncher.

the class DiagnosticHandler method process.

@Override
public void process(@Nonnull final EntityPlayer player) {
    // Gather diagnostics if needed
    if (Minecraft.getMinecraft().gameSettings.showDebugInfo) {
        this.diagnostics = new ArrayList<>();
        if (DSurround.isDeveloperMode())
            this.diagnostics.add(TextFormatting.RED + "DEVELOPER MODE ENABLED");
        if (ModOptions.logging.enableDebugLogging) {
            final DiagnosticEvent.Gather gather = new DiagnosticEvent.Gather(player.getEntityWorld(), player);
            MinecraftForge.EVENT_BUS.post(gather);
            this.diagnostics.addAll(gather.output);
        }
    } else {
        this.diagnostics = null;
    }
    if (ModOptions.logging.showDebugDialog)
        DiagnosticPanel.refresh();
    if (DSurround.isDeveloperMode()) {
        final ParticleManager pm = Minecraft.getMinecraft().effectRenderer;
        if (!(pm instanceof TraceParticleManager)) {
            DSurround.log().info("Wrapping particle manager [%s]", pm.getClass().getName());
            Minecraft.getMinecraft().effectRenderer = new TraceParticleManager(pm);
        }
    }
}
Also used : DiagnosticEvent(org.blockartistry.DynSurround.event.DiagnosticEvent) TraceParticleManager(org.blockartistry.DynSurround.client.handlers.trace.TraceParticleManager) TraceParticleManager(org.blockartistry.DynSurround.client.handlers.trace.TraceParticleManager) ParticleManager(net.minecraft.client.particle.ParticleManager)

Example 14 with ParticleManager

use of net.minecraft.client.particle.ParticleManager in project EnderIO by SleepyTrousers.

the class BlockVat method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) {
    // Spit some "steam" out the spout
    TileVat te = getTileEntity(world, pos);
    if (te != null && te.isActive()) {
        float pX = pos.getX() + 0.5f;
        float pY = pos.getY() + 0.7f;
        float pZ = pos.getZ() + 0.5f;
        EnumFacing dir = te.getFacing();
        pX += 0.6f * dir.getFrontOffsetX();
        pZ += 0.6f * dir.getFrontOffsetZ();
        double velX = ((rand.nextDouble() * 0.075) + 0.025) * dir.getFrontOffsetX();
        double velZ = ((rand.nextDouble() * 0.075) + 0.025) * dir.getFrontOffsetZ();
        int num = rand.nextInt(4) + 2;
        for (int k = 0; k < num; k++) {
            ParticleManager er = Minecraft.getMinecraft().effectRenderer;
            Particle fx = er.spawnEffectParticle(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), pX, pY, pZ, 1, 1, 1, 0);
            if (fx != null) {
                fx.setRBGColorF(1 - (rand.nextFloat() * 0.2f), 1 - (rand.nextFloat() * 0.1f), 1 - (rand.nextFloat() * 0.2f));
                ClientUtil.setParticleVelocity(fx, velX, -0.06, velZ);
            }
        }
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) EnumFacing(net.minecraft.util.EnumFacing) ParticleManager(net.minecraft.client.particle.ParticleManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with ParticleManager

use of net.minecraft.client.particle.ParticleManager in project ForestryMC by ForestryMC.

the class ParticleRender method addBeeHiveFX.

public static void addBeeHiveFX(IBeeHousing housing, IBeeGenome genome, List<BlockPos> flowerPositions) {
    World world = housing.getWorldObj();
    if (!shouldSpawnParticle(world)) {
        return;
    }
    ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer;
    Vec3d particleStart = housing.getBeeFXCoordinates();
    // Avoid rendering bee particles that are too far away, they're very small.
    // At 32+ distance, have no bee particles. Make more particles up close.
    BlockPos playerPosition = Minecraft.getMinecraft().player.getPosition();
    double playerDistanceSq = playerPosition.distanceSqToCenter(particleStart.x, particleStart.y, particleStart.z);
    if (world.rand.nextInt(1024) < playerDistanceSq) {
        return;
    }
    int color = genome.getPrimary().getSpriteColour(0);
    int randomInt = world.rand.nextInt(100);
    if (housing instanceof IHiveTile) {
        if (((IHiveTile) housing).isAngry() || randomInt >= 85) {
            List<EntityLivingBase> entitiesInRange = AlleleEffect.getEntitiesInRange(genome, housing, EntityLivingBase.class);
            if (!entitiesInRange.isEmpty()) {
                EntityLivingBase entity = entitiesInRange.get(world.rand.nextInt(entitiesInRange.size()));
                Particle particle = new ParticleBeeTargetEntity(world, particleStart, entity, color);
                effectRenderer.addEffect(particle);
                return;
            }
        }
    }
    if (randomInt < 75 && !flowerPositions.isEmpty()) {
        BlockPos destination = flowerPositions.get(world.rand.nextInt(flowerPositions.size()));
        Particle particle = new ParticleBeeRoundTrip(world, particleStart, destination, color);
        effectRenderer.addEffect(particle);
    } else {
        Vec3i area = AlleleEffect.getModifiedArea(genome, housing);
        Vec3i offset = housing.getCoordinates().add(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
        BlockPos destination = VectUtil.getRandomPositionInArea(world.rand, area).add(offset);
        Particle particle = new ParticleBeeExplore(world, particleStart, destination, color);
        effectRenderer.addEffect(particle);
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) World(net.minecraft.world.World) ParticleBeeExplore(forestry.apiculture.entities.ParticleBeeExplore) Vec3d(net.minecraft.util.math.Vec3d) ParticleBeeTargetEntity(forestry.apiculture.entities.ParticleBeeTargetEntity) Particle(net.minecraft.client.particle.Particle) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ParticleManager(net.minecraft.client.particle.ParticleManager) BlockPos(net.minecraft.util.math.BlockPos) IHiveTile(forestry.api.apiculture.IHiveTile) ParticleBeeRoundTrip(forestry.apiculture.entities.ParticleBeeRoundTrip)

Aggregations

ParticleManager (net.minecraft.client.particle.ParticleManager)16 Particle (net.minecraft.client.particle.Particle)9 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 IBlockState (net.minecraft.block.state.IBlockState)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 AbstractMachineEntity (crazypants.enderio.base.machine.base.te.AbstractMachineEntity)1 IHiveTile (forestry.api.apiculture.IHiveTile)1 ParticleBeeExplore (forestry.apiculture.entities.ParticleBeeExplore)1 ParticleBeeRoundTrip (forestry.apiculture.entities.ParticleBeeRoundTrip)1 ParticleBeeTargetEntity (forestry.apiculture.entities.ParticleBeeTargetEntity)1 ParticleHoneydust (forestry.core.entities.ParticleHoneydust)1 ParticleIgnition (forestry.core.entities.ParticleIgnition)1 ParticleSmoke (forestry.core.entities.ParticleSmoke)1 ParticleSnow (forestry.core.entities.ParticleSnow)1 Random (java.util.Random)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1