package dangerzone.entities;

import dangerzone.DangerZone;
import dangerzone.Effects;
import dangerzone.Player;
import dangerzone.World;

public class ThrownFrog extends ThrownBlockItem {

	public ThrownFrog(World w) {
		super(w);
	}
	
	public void doHitSomething(boolean hb, double x, double y, double z, boolean he, Entity ent){

		if(he && ent != null){
			Effects ef = null;
			for(int i=0;i<effect_list.size();i++){
				ef = effect_list.get(i);
				ent.addEffect(ef);
				if(ent instanceof Player){
					Player p = (Player)ent;
					p.server_thread.sendNewEffect(ef);
				}
			}
		}else{
			//change back into an item/block
			EntityBlockItem ee = (EntityBlockItem)world.createEntityByName(DangerZone.blockitemname, dimension, posx+motionx, posy+motiony, posz+motionz);
			if(ee != null){
				ee.init();
				ee.setBID(this.getBID());
				ee.setIID(this.getIID());					
				world.spawnEntityInWorld(ee);
			}
		}
		world.playSound("DangerZone:little_splat", dimension, posx+motionx, posy+motiony, posz+motionz, 0.5f, 1.0f+((world.rand.nextFloat()-world.rand.nextFloat())*0.3f));
	}

}
