Program: 27625
Project: 27625
Buggy source:
/** 
 * Gets the list of packets that are needed to spawn the particle effect at the position. This method tries to minimize the amount of packets for better performance and lower bandwidth use.
 * @param effect The particle effect
 * @param position The position
 * @return The packets
 */
public static List<Packet> toPackets(SpongeParticleEffect effect,Vector3d position){
  SpongeParticleType type=effect.getType();
  EnumParticleTypes internal=type.getInternalType();
  Vector3f offset=effect.getOffset();
  int count=effect.getCount();
  int[] extra=new int[0];
  float px=(float)position.getX();
  float py=(float)position.getY();
  float pz=(float)position.getZ();
  float ox=offset.getX();
  float oy=offset.getY();
  float oz=offset.getZ();
  float f0=0f;
  float f1=0f;
  float f2=0f;
  if (effect instanceof SpongeParticleEffect.Materialized) {
    ItemStack item=((SpongeParticleEffect.Materialized)effect).getItem();
    ItemType itemType=item.getItem();
    int id=0;
    int data=0;
    if (internal == EnumParticleTypes.ITEM_CRACK) {
      id=Item.itemRegistry.getIDForObject(itemType);
      data=item.getDamage();
    }
 else     if (internal == EnumParticleTypes.BLOCK_CRACK || internal == EnumParticleTypes.BLOCK_DUST) {
      if (itemType instanceof ItemBlock) {
        id=Block.blockRegistry.getIDForObject(((ItemBlock)itemType).getBlock());
        data=item.getDamage();
      }
    }
    if (id == 0) {
      return Collections.emptyList();
    }
    extra=new int[]{id,data};
  }
  if (effect instanceof SpongeParticleEffect.Resized) {
    float size=((SpongeParticleEffect.Resized)effect).getSize();
    if (internal == EnumParticleTypes.EXPLOSION_LARGE) {
      size=(-size * 2f) + 2f;
    }
    if (size == 0f) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
    f0=size;
  }
 else   if (effect instanceof SpongeParticleEffect.Colored) {
    Color color0=((SpongeParticleEffect.Colored)effect).getColor();
    Color color1=((SpongeParticleType.Colorable)type).getDefaultColor();
    if (color0.equals(color1)) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
    f0=color0.getRed() / 255f;
    f1=color0.getGreen() / 255f;
    f2=color0.getBlue() / 255f;
    if (f0 == 0f && internal == EnumParticleTypes.REDSTONE) {
      f0=0.00001f;
    }
  }
 else   if (effect instanceof SpongeParticleEffect.Note) {
    float note=((SpongeParticleEffect.Note)effect).getNote();
    if (note == 0f) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
    f0=note / 24f;
  }
 else   if (type.hasMotion()) {
    Vector3f motion=effect.getMotion();
    float mx=motion.getX();
    float my=motion.getY();
    float mz=motion.getZ();
    if (internal == EnumParticleTypes.WATER_SPLASH) {
      my=0f;
    }
    if (mx == 0f && my == 0f && mz == 0f) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
 else {
      f0=mx;
      f1=my;
      f2=mz;
    }
  }
  if (f0 == 0f && f1 == 0f && f2 == 0f) {
    return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
  }
  List<Packet> packets=Lists.newArrayList();
  if (ox == 0f && oy == 0f && oz == 0f) {
    for (int i=0; i < count; i++) {
      packets.add(new S2APacketParticles(internal,true,px,py,pz,f0,f1,f2,1f,0,extra));
    }
  }
 else {
    Random random=new Random();
    for (int i=0; i < count; i++) {
      float px0=(float)(px + (random.nextFloat() * 2f - 1f) * ox);
      float py0=(float)(py + (random.nextFloat() * 2f - 1f) * oy);
      float pz0=(float)(pz + (random.nextFloat() * 2f - 1f) * oz);
      packets.add(new S2APacketParticles(internal,true,px0,py0,pz0,f0,f1,f2,1f,0,extra));
    }
  }
  return packets;
}

Fixed version (ground truth):
/** 
 * Gets the list of packets that are needed to spawn the particle effect at the position. This method tries to minimize the amount of packets for better performance and lower bandwidth use.
 * @param effect The particle effect
 * @param position The position
 * @return The packets
 */
public static List<Packet> toPackets(SpongeParticleEffect effect,Vector3d position){
  SpongeParticleType type=effect.getType();
  EnumParticleTypes internal=type.getInternalType();
  Vector3f offset=effect.getOffset();
  int count=effect.getCount();
  int[] extra=new int[0];
  float px=(float)position.getX();
  float py=(float)position.getY();
  float pz=(float)position.getZ();
  float ox=offset.getX();
  float oy=offset.getY();
  float oz=offset.getZ();
  float f0=0f;
  float f1=0f;
  float f2=0f;
  if (effect instanceof SpongeParticleEffect.Materialized) {
    ItemStack item=((SpongeParticleEffect.Materialized)effect).getItem();
    ItemType itemType=item.getItem();
    int id=0;
    int data=0;
    if (internal == EnumParticleTypes.ITEM_CRACK) {
      id=Item.itemRegistry.getIDForObject(itemType);
      data=item.getDamage();
    }
 else     if (internal == EnumParticleTypes.BLOCK_CRACK || internal == EnumParticleTypes.BLOCK_DUST) {
      if (itemType instanceof ItemBlock) {
        id=Block.blockRegistry.getIDForObject(((ItemBlock)itemType).getBlock());
        data=item.getDamage();
      }
    }
    if (id == 0) {
      return Collections.emptyList();
    }
    extra=new int[]{id,data};
  }
  if (effect instanceof SpongeParticleEffect.Resized) {
    float size=((SpongeParticleEffect.Resized)effect).getSize();
    if (internal == EnumParticleTypes.EXPLOSION_LARGE) {
      size=(-size * 2f) + 2f;
    }
    if (size == 0f) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
    f0=size;
  }
 else   if (effect instanceof SpongeParticleEffect.Colored) {
    Color color0=((SpongeParticleEffect.Colored)effect).getColor();
    Color color1=((SpongeParticleType.Colorable)type).getDefaultColor();
    if (color0.equals(color1)) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
    f0=color0.getRed() / 255f;
    f1=color0.getGreen() / 255f;
    f2=color0.getBlue() / 255f;
    if (f0 == 0f && internal == EnumParticleTypes.REDSTONE) {
      f0=0.00001f;
    }
  }
 else   if (effect instanceof SpongeParticleEffect.Note) {
    float note=((SpongeParticleEffect.Note)effect).getNote();
    if (note == 0f) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
    f0=note / 24f;
  }
 else   if (type.hasMotion()) {
    Vector3f motion=effect.getMotion();
    float mx=motion.getX();
    float my=motion.getY();
    float mz=motion.getZ();
    if (internal == EnumParticleTypes.WATER_SPLASH) {
      my=0f;
    }
    if (mx == 0f && my == 0f && mz == 0f) {
      return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
    }
 else {
      f0=mx;
      f1=my;
      f2=mz;
    }
  }
  if (f0 == 0f && f1 == 0f && f2 == 0f) {
    return Lists.<Packet>newArrayList(new S2APacketParticles(internal,true,px,py,pz,ox,oy,oz,0f,count,extra));
  }
  List<Packet> packets=Lists.newArrayList();
  if (ox == 0f && oy == 0f && oz == 0f) {
    for (int i=0; i < count; i++) {
      packets.add(new S2APacketParticles(internal,true,px,py,pz,f0,f1,f2,1f,0,extra));
    }
  }
 else {
    Random random=new Random();
    for (int i=0; i < count; i++) {
      float px0=(px + (random.nextFloat() * 2f - 1f) * ox);
      float py0=(py + (random.nextFloat() * 2f - 1f) * oy);
      float pz0=(pz + (random.nextFloat() * 2f - 1f) * oz);
      packets.add(new S2APacketParticles(internal,true,px0,py0,pz0,f0,f1,f2,1f,0,extra));
    }
  }
  return packets;
}