use of net.minecraft.client.particle.Particle in project EnderIO by SleepyTrousers.
the class PaintHelper method addBlockHitEffects.
@SideOnly(Side.CLIENT)
public static void addBlockHitEffects(@Nonnull World world, @Nonnull IBlockState realBlock, @Nonnull IBlockState paintBlock, @Nonnull BlockPos pos, @Nonnull EnumFacing side, @Nonnull ParticleManager effectRenderer) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
float f = 0.1F;
AxisAlignedBB axisalignedbb = realBlock.getBoundingBox(world, pos);
double d0 = i + rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - f * 2.0F) + f + axisalignedbb.minX;
double d1 = j + rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - f * 2.0F) + f + axisalignedbb.minY;
double d2 = k + rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - f * 2.0F) + f + axisalignedbb.minZ;
switch(side) {
case DOWN:
d1 = j + axisalignedbb.minY - f;
break;
case UP:
d1 = j + axisalignedbb.maxY + f;
break;
case NORTH:
d2 = k + axisalignedbb.minZ - f;
break;
case SOUTH:
d2 = k + axisalignedbb.maxZ + f;
break;
case WEST:
d0 = i + axisalignedbb.minX - f;
break;
case EAST:
d0 = i + axisalignedbb.maxX + f;
break;
}
// this state sets the gravity and texture. this pos sets the lighting, so we better use our block pos
Particle digFX = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), i, j, k, 0, 0, 0, Block.getStateId(paintBlock));
if (digFX instanceof ParticleDigging) {
// this pos sets the tint...wrongly
((ParticleDigging) digFX).setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
// manually fixing the tint
if (paintBlock.getBlock() == Blocks.GRASS) {
digFX.setRBGColorF(0.6f, 0.6f, 0.6f);
} else {
int tint = Minecraft.getMinecraft().getBlockColors().colorMultiplier(paintBlock, world, pos, 0);
float particleRed = 0.6f * (tint >> 16 & 255) / 255.0F;
float particleGreen = 0.6f * (tint >> 8 & 255) / 255.0F;
float particleBlue = 0.6f * (tint & 255) / 255.0F;
digFX.setRBGColorF(particleRed, particleGreen, particleBlue);
}
// / and this is the pos we actually want the particle to be
digFX.setPosition(d0, d1, d2);
// and that's it, spawn my monkeys, spawn!
}
}
use of net.minecraft.client.particle.Particle 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);
}
}
}
}
use of net.minecraft.client.particle.Particle in project ForestryMC by ForestryMC.
the class BlockForestryFluid method randomDisplayTick.
/**
* Copied from {@link BlockLiquid#randomDisplayTick(IBlockState, World, BlockPos, Random)}
* and modified to have colored particles.
*/
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
double d0 = pos.getX();
double d1 = pos.getY();
double d2 = pos.getZ();
if (this.blockMaterial == Material.WATER) {
int i = stateIn.getValue(LEVEL);
if (i > 0 && i < 8) {
if (getFluid().getViscosity(worldIn, pos) < 5000 && rand.nextInt(64) == 0) {
worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() + 0.5F, false);
}
} else if (rand.nextInt(10) == 0) {
worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + rand.nextFloat(), d1 + rand.nextFloat(), d2 + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
if (this.blockMaterial == Material.LAVA && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && !worldIn.getBlockState(pos.up()).isOpaqueCube()) {
if (rand.nextInt(100) == 0) {
double d8 = d0 + rand.nextFloat();
double d4 = d1 + stateIn.getBoundingBox(worldIn, pos).maxY;
double d6 = d2 + rand.nextFloat();
worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D);
worldIn.playSound(d8, d4, d6, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
}
if (rand.nextInt(200) == 0) {
worldIn.playSound(d0, d1, d2, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
}
}
if (rand.nextInt(10) == 0 && worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.DOWN)) {
Material material = worldIn.getBlockState(pos.down(2)).getMaterial();
if (!material.blocksMovement() && !material.isLiquid()) {
double px = d0 + rand.nextFloat();
double py = d1 - 1.05D;
double pz = d2 + rand.nextFloat();
Particle fx = new ParticleColoredDripParticle(worldIn, px, py, pz, color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
}
use of net.minecraft.client.particle.Particle 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);
}
}
use of net.minecraft.client.particle.Particle in project Binnie by ForestryMC.
the class InoculatorFX method onDisplayTick.
@SideOnly(Side.CLIENT)
@Override
public void onDisplayTick(World world, BlockPos pos, Random rand) {
if (!this.getUtil().getProcess().isInProgress())
return;
final int tick = (int) (world.getTotalWorldTime() % 3L);
if (tick == 0) {
final Particle particle = new InoculatorParticle(world, pos);
BinnieCore.getBinnieProxy().getMinecraftInstance().effectRenderer.addEffect(particle);
}
}
Aggregations