Search in sources :

Example 1 with ParticleBeeRoundTrip

use of forestry.apiculture.entities.ParticleBeeRoundTrip 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

IHiveTile (forestry.api.apiculture.IHiveTile)1 ParticleBeeExplore (forestry.apiculture.entities.ParticleBeeExplore)1 ParticleBeeRoundTrip (forestry.apiculture.entities.ParticleBeeRoundTrip)1 ParticleBeeTargetEntity (forestry.apiculture.entities.ParticleBeeTargetEntity)1 Particle (net.minecraft.client.particle.Particle)1 ParticleManager (net.minecraft.client.particle.ParticleManager)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3d (net.minecraft.util.math.Vec3d)1 Vec3i (net.minecraft.util.math.Vec3i)1 World (net.minecraft.world.World)1