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