Search in sources :

Example 1 with IHiveTile

use of forestry.api.apiculture.IHiveTile in project ForestryMC by ForestryMC.

the class ItemSmoker method addSmoke.

private static void addSmoke(ItemStack stack, World world, Entity entity, int distance) {
    if (distance <= 0) {
        return;
    }
    Vec3d look = entity.getLookVec();
    EnumHandSide handSide = getHandSide(stack, entity);
    Vec3d handOffset;
    if (handSide == EnumHandSide.RIGHT) {
        handOffset = look.crossProduct(new Vec3d(0, 1, 0));
    } else {
        handOffset = look.crossProduct(new Vec3d(0, -1, 0));
    }
    Vec3d lookDistance = new Vec3d(look.x * distance, look.y * distance, look.z * distance);
    Vec3d scaledOffset = handOffset.scale(1.0 / distance);
    Vec3d smokePos = lookDistance.add(entity.getPositionVector()).add(scaledOffset);
    if (world.isRemote) {
        ParticleRender.addEntitySmokeFX(world, smokePos.x, smokePos.y + 1, smokePos.z);
    }
    BlockPos blockPos = new BlockPos(smokePos.x, smokePos.y + 1, smokePos.z);
    TileUtil.actOnTile(world, blockPos, IHiveTile.class, IHiveTile::calmBees);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) IHiveTile(forestry.api.apiculture.IHiveTile) EnumHandSide(net.minecraft.util.EnumHandSide)

Example 2 with IHiveTile

use of forestry.api.apiculture.IHiveTile 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)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vec3d (net.minecraft.util.math.Vec3d)2 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 EnumHandSide (net.minecraft.util.EnumHandSide)1 Vec3i (net.minecraft.util.math.Vec3i)1 World (net.minecraft.world.World)1