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);
}
}
Aggregations