Java Code Examples for net.minecraft.world.World#spawnParticle()

The following examples show how to use net.minecraft.world.World#spawnParticle() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
protected boolean spawnCustomParticles() {
  int i = this.getSlimeSize();
  for (int j = 0; j < i * 8; ++j) {
    float f = this.rand.nextFloat() * ((float) Math.PI * 2F);
    float f1 = this.rand.nextFloat() * 0.5F + 0.5F;
    float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1;
    float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1;
    World world = this.world;
    EnumParticleTypes enumparticletypes = this.getParticleType();
    double d0 = this.posX + (double) f2;
    double d1 = this.posZ + (double) f3;
    world.spawnParticle(enumparticletypes, d0, this.getEntityBoundingBox().minY, d1, 0.0D, 0.0D, 0.0D, Block.getStateId(Blocks.DIRT.getDefaultState()));
  }
  return true;
}
 
Example 2
Source Project: TofuCraftReload   File: BlockNattoBed.java    License: MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    if (isUnderWeight(worldIn, pos)) {
        if (canFerm(stateIn)) {
            if (rand.nextInt(5) == 0) {
                double d4 = rand.nextBoolean() ? 0.8 : -0.8;
                double d0 = ((float) pos.getX() + 0.5 + (rand.nextFloat() * d4));
                double d1 = (double) ((float) pos.getY() + rand.nextFloat());
                double d2 = ((float) pos.getZ() + 0.5 + rand.nextFloat() * d4);

                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D);
            }
        }

    }
}
 
Example 3
Source Project: TofuCraftReload   File: BlockTFStorage.java    License: MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {

    boolean lit = (Boolean) stateIn.getValue(LIT);
    if (lit) {
        if (rand.nextInt(2) == 0) {
            double d4 = rand.nextBoolean() ? 0.05 : -0.05;
            double d0 = ((float) pos.getX() + 0.5 + (rand.nextFloat() * d4));
            double d1 = (double) ((float) pos.getY() + 0.8);
            double d2 = ((float) pos.getZ() + 0.5 + rand.nextFloat() * d4);

            worldIn.spawnParticle(EnumParticleTypes.CLOUD, d0, d1, d2, 0.0D, 0.35D, 0.0D);
        }
    }
}
 
Example 4
public static void spawnParticlesAround(World world, EnumParticleTypes type, BlockPos pos, int count, Random rand)
{
    for (int i = 0; i < count; ++i)
    {
        int i1 = rand.nextInt(2) * 2 - 1;
        int j1 = rand.nextInt(2) * 2 - 1;

        double x1 = (double)pos.getX() + 0.5D + 0.25D * (double)i1;
        double y1 = (double)((float)pos.getY() + rand.nextFloat());
        double z1 = (double)pos.getZ() + 0.5D + 0.25D * (double)j1;

        double vx = (double)(rand.nextFloat() * 1.0F * (float)i1);
        double vy = ((double)rand.nextFloat() - 0.5D) * 0.125D;
        double vz = (double)(rand.nextFloat() * 1.0F * (float)j1);

        world.spawnParticle(type, x1, y1, z1, vx, vy, vz);
    }
}
 
Example 5
Source Project: Production-Line   File: BlockMachine.java    License: MIT License 6 votes vote down vote up
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    TileEntity te = worldIn.getTileEntity(pos);
    if (te instanceof TileCarbonizeFurnace) {
        if (((TileCarbonizeFurnace) te).active) {
            float xmod;
            float ymod;
            float zmod;

            float x = (float)pos.getX() + 1.0F;
            float y = (float)pos.getY() + 1.0F;
            float z = (float)pos.getZ() + 1.0F;

            for(int i = 0; i < 4; ++i) {
                xmod = -0.2F - rand.nextFloat() * 0.6F;
                ymod = -0.1F + rand.nextFloat() * 0.2F;
                zmod = -0.2F - rand.nextFloat() * 0.6F;
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(x + xmod), (double)(y + ymod),
                        (double)(z + zmod), 0.0D, 0.0D, 0.0D);
            }
        }
    }
}
 
Example 6
Source Project: TofuCraftReload   File: BlockSaltFurnace.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("incomplete-switch")
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
    if (this.isBurning)
    {
        EnumFacing enumfacing = (EnumFacing)stateIn.getValue(FACING);
        double d0 = (double)pos.getX() + 0.5D;
        double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
        double d2 = (double)pos.getZ() + 0.5D;
        double d4 = rand.nextDouble() * 0.6D - 0.3D;

        if (rand.nextDouble() < 0.1D)
        {
            worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
        }

        switch (enumfacing)
        {
            case WEST:
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
                worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
                break;
            case EAST:
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
                worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
                break;
            case NORTH:
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - 0.52D, 0.0D, 0.0D, 0.0D);
                worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - 0.52D, 0.0D, 0.0D, 0.0D);
                break;
            case SOUTH:
                worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + 0.52D, 0.0D, 0.0D, 0.0D);
                worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + 0.52D, 0.0D, 0.0D, 0.0D);
        }
    }
}
 
Example 7
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {
	if (emitsParticles) {
		int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
		double d0 = (double) ((float) p_149734_2_ + 0.5F);
		double d1 = (double) ((float) p_149734_3_ + 0.7F);
		double d2 = (double) ((float) p_149734_4_ + 0.5F);
		double d3 = 0.2199999988079071D;
		double d4 = 0.27000001072883606D;

		if (l == 1) {
			p_149734_1_.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
		} else if (l == 2) {
			p_149734_1_.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
		} else if (l == 3) {
			p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
		} else if (l == 4) {
			p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
		} else {
			p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
		}
	}
}
 
Example 8
Source Project: Sakura_mod   File: BlockCampfirePot.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    double d0 = pos.getX() + 0.5D;
    double d2 = pos.getZ() + 0.5D;
    double d4 = rand.nextDouble() * 0.4D - 0.2D;
    if (this.isBurning) {
        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);
        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);

        if (rand.nextDouble() < 0.15D) {
            worldIn.playSound(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
        }
    }
}
 
Example 9
Source Project: Sakura_mod   File: BlockCampfire.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    double d0 = pos.getX() + 0.5D;
    double d2 = pos.getZ() + 0.5D;
    double d4 = rand.nextDouble() * 0.4D - 0.2D;
    if (this.isBurning) {
        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);
        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);
    }
}
 
Example 10
public static void spawnParticles(World worldIn, BlockPos pos, EnumFacing direction, EnumParticleTypes particleType, int particleCount, Random rand) {
    for (int i = 0; i < particleCount; i++) {
        worldIn.spawnParticle(particleType,
            pos.getX() + 0.5 - direction.getFrontOffsetX() / 1.8,
            pos.getY() + 0.5 - direction.getFrontOffsetY() / 1.8,
            pos.getZ() + 0.5 - direction.getFrontOffsetZ() / 1.8,
            direction.getFrontOffsetX() * 0.2 + rand.nextDouble() * 0.1,
            direction.getFrontOffsetY() * 0.2 + rand.nextDouble() * 0.1,
            direction.getFrontOffsetZ() * 0.2 + rand.nextDouble() * 0.1);
    }
}
 
Example 11
@Override
@SideOnly(Side.CLIENT)
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (this.isActive) {
		for (int i = 0; i < 3; ++i) {
			double d0 = (double) pos.getX() + rand.nextDouble();
			double d1 = (double) pos.getY() + .5D + rand.nextDouble() * 0.5D + 0.5D;
			double d2 = (double) pos.getZ() + rand.nextDouble();
			worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D);
		}
	}
}
 
Example 12
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
    super.randomDisplayTick(par1World, par2, par3, par4, par5Random);

    if (par5Random.nextInt(75) == 0)
    {
        par1World.spawnParticle("depthsuspend", (float)par2 + par5Random.nextFloat(), (float)par3 + 1.1F, (float)par4 + par5Random.nextFloat(), 20.0D, 20.0D, 20.0D);
    }
}
 
Example 13
Source Project: GardenCollection   File: VanillaLanternSource.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderParticle (World world, int x, int y, int z, Random rand, int meta) {
    double px = x + .5f + (rand.nextFloat() - 0.5F) * 0.2D;
    double py = y + .6f + (rand.nextFloat() - 0.5F) * 0.2D + 0.1F;
    double pz = z + .5f + (rand.nextFloat() - 0.5F) * 0.2D;

    world.spawnParticle("reddust", px, py, pz, 0.0D, 0.0D, 0.0D);
}
 
Example 14
public static void indicateBlock(World world, int x, int y, int z){

        if(world != null) {
            if(world.isRemote) {
                for(int i = 0; i < 5; i++) {
                    double dx = x + 0.5;
                    double dy = y + 0.5;
                    double dz = z + 0.5;
                    world.spawnParticle("reddust", dx, dy, dz, 0, 0, 0);
                }
            } else {
                NetworkHandler.sendToAllAround(new PacketDebugBlock(x, y, z), world);
            }
        }
    }
 
Example 15
Source Project: GardenCollection   File: CandleLanternSource.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderParticle (World world, int x, int y, int z, Random rand, int meta) {
    double px = x + 0.5F;
    double py = y + 0.625F;
    double pz = z + 0.5F;

    world.spawnParticle("flame", px, py, pz, 0.0D, 0.0D, 0.0D);
}
 
Example 16
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
    if(world.getBlockMetadata(x, y, z) == 14) world.spawnParticle("largesmoke", x + 0.5D, y + 0.9D, z + 0.5D, 0, 0, 0);
}
 
Example 17
@Override
@SideOnly(Side.CLIENT)
public void explodeEffect(World world, double x, double y, double z) {

  List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, EntityUtil.getBoundsAround(x, y, z, Config.confusingChargeRange));
  if (players != null) {

    double maxDistanceSq = Config.confusingChargeRange * Config.confusingChargeRange;
    for (EntityPlayer player : players) {
      double playerDistSq = player.getDistanceSq(x, y, z);
      if (playerDistSq < maxDistanceSq) {
        double scale = 1 - playerDistSq / maxDistanceSq;
        scale = Math.exp(scale) / Math.E;
        int duration = (int) Math.ceil(Config.confusingChargeEffectDuration * scale);
        EnderZoo.proxy.setInstantConfusionOnPlayer(player, duration);
      }
    }
  }

  // world.spawnParticle("hugeexplosion", x, y, z, 1.0D, 0.0D, 0.0D);
  world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, x, y, z, 1.0D, 0.0D, 0.0D);

  int col = MobEffects.NAUSEA.getLiquidColor();
  float r = (col >> 16 & 255) / 255.0F;
  float g = (col >> 8 & 255) / 255.0F;
  float b = (col >> 0 & 255) / 255.0F;
  Random random = world.rand;
  for (int i = 0; i < 100; ++i) {
    // double seed = random.nextDouble() * 20.0D;

    double d = random.nextDouble() * 2D;
    double mag = 25;
    double motionX = (0.5 - random.nextDouble()) * mag * d;
    double motionY = (0.5 - random.nextDouble()) * mag;
    double motionZ = (0.5 - random.nextDouble()) * mag * d;

    ParticleSpell entityfx = (ParticleSpell) new ParticleSpell.InstantFactory().createParticle(i, world, x + motionX * 0.1,
        y + motionY * 0.1, z + motionZ * 0.1, motionX, motionY, motionZ, (int[]) null);
    float colRan = 0.75F + random.nextFloat() * 0.25F;
    entityfx.setRBGColorF(r * colRan, g * colRan, b * colRan);
    entityfx.multiplyVelocity(0.1f);      
    Minecraft.getMinecraft().effectRenderer.addEffect(entityfx);

  }

}
 
Example 18
public static boolean teleportTo(EntityLivingBase entity, double x, double y, double z, boolean fireEndermanEvent) {

    EnderTeleportEvent event = new EnderTeleportEvent(entity, x, y, z, 0);
    if (fireEndermanEvent) {
      if (MinecraftForge.EVENT_BUS.post(event)) {
        return false;
      }
    }

    double origX = entity.posX;
    double origY = entity.posY;
    double origZ = entity.posZ;
    entity.posX = event.getTargetX();
    entity.posY = event.getTargetY();
    entity.posZ = event.getTargetZ();

    int xInt = MathHelper.floor(entity.posX);
    int yInt = Math.max(2, MathHelper.floor(entity.posY));
    int zInt = MathHelper.floor(entity.posZ);

    boolean doTeleport = false;
    World worldObj = entity.getEntityWorld();
    if (worldObj.isBlockLoaded(new BlockPos(xInt, yInt, zInt), true)) {
      boolean foundGround = false;
      while (!foundGround && yInt > 2) {
        IBlockState bs = worldObj.getBlockState(new BlockPos(xInt, yInt - 1, zInt));
        if (bs != null && bs.getBlock() != null && bs.getMaterial().blocksMovement()) {
          foundGround = true;
        } else {
          --entity.posY;
          --yInt;
        }
      }

      if (foundGround) {
        entity.setPosition(entity.posX, entity.posY, entity.posZ);
        if (worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty()
            && !worldObj.containsAnyLiquid(entity.getEntityBoundingBox())) {
          doTeleport = true;
        } else if (yInt <= 0) {
          doTeleport = false;
        }
      }
    }

    if (!doTeleport) {
      entity.setPosition(origX, origY, origZ);
      return false;
    }

    entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);

    short short1 = 128;
    for (int l = 0; l < short1; ++l) {
      double d6 = l / (short1 - 1.0D);
      float f = (rand.nextFloat() - 0.5F) * 0.2F;
      float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
      float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
      double d7 = origX + (entity.posX - origX) * d6 + (rand.nextDouble() - 0.5D) * entity.width * 2.0D;
      double d8 = origY + (entity.posY - origY) * d6 + rand.nextDouble() * entity.height;
      double d9 = origZ + (entity.posZ - origZ) * d6 + (rand.nextDouble() - 0.5D) * entity.width * 2.0D;
      worldObj.spawnParticle(EnumParticleTypes.PORTAL, d7, d8, d9, f, f1, f2);
    }

    worldObj.playSound(origX, origY, origZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
    entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
    return true;

  }
 
Example 19
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count)
{
	World world = player.world;



	int duration = getMaxItemUseDuration(stack) - count;
	int chance = getMaxItemUseDuration(stack) - duration;
	int rand = world.rand.nextInt(chance);

	BlockPos pos = null;
	RayTraceResult result = rayTrace(player, 3, 0);
	if(result != null && result.typeOfHit == RayTraceResult.Type.BLOCK)
	{
		pos = result.getBlockPos();			
	}
	else return;

	if(!world.isRemote)
	{
		if(count < 200)
			return;

		if(count % 10 == 1)
			world.playSound(null, pos, TFC_Sounds.FIRESTARTER, SoundCategory.BLOCKS, 1.0f, 1.0f);
		if(rand < 20 && pos != null)
			onUse(world, player, stack, pos, count);

		if(stack.getItemDamage()+duration > stack.getMaxDamage())
		{
			stack.damageItem(duration, player);
			player.stopActiveHand();
		}
	}
	else
	{
		if(count > 0 )
			world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX()+world.rand.nextDouble(), pos.getY()+1, pos.getZ()+world.rand.nextDouble(), 0, 0.01, 0);
	}
}
 
Example 20
Source Project: Ex-Aliquo   File: BlockEndEye.java    License: MIT License 4 votes vote down vote up
@Override
   public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
{
	int vel = rand.nextInt()*2-1;
	world.spawnParticle("portal", (double)(x*rand.nextFloat()), (double)(y*rand.nextFloat()), (double)(z*rand.nextFloat()), (double)((float)vel*rand.nextFloat()*1.0F), (double)((float)vel*rand.nextFloat()*1.0F), (double)((float)vel*rand.nextFloat()*1.0F));
}