@name Minecraft E2 - By Croco
@inputs 
@outputs 
@persist A Aim:vector Pos:vector Hold
@trigger 
interval(10)

Target = find()
User = owner()
AimPos = User:aimPos()
Fire = User:keyAttack2()
#RedDot = owner():aimPos()
UserEye = User:eye()
Break = owner():keyAttack2() & owner():aimPos()
R_aim = owner():aimPos()


#[if(changed(Fire) & Fire == 1)
{
    E = propSpawn("models/hunter/blocks/cube1x1x1.mdl",AimPos+vec(0,0,25),0)   
    #E:applyForce(vec(0,0,50)*-5000)
    E:propFreeze(1)
}
]#
Grid = 35
 Hold=0   
 Di=100
Aim = owner():aimPos()
Pos = (round(Aim/Grid)*Grid+vec(0,0,Grid/2))
holoPos(1,Pos)
holoAng(1,(holoEntity(1):pos()-(owner():pos()+vec(0,0,70))):toAngle()+ang(-90,0,0))
if(A>0){A-=1}
if(owner():aimEntity()&A<1&Hold==0&owner():aimEntity():model()=="models/hunter/blocks/cube1x1x1.mdl"&owner():aimPos():distance(owner():pos())<Di&owner():keyAttack1()){
  
    A=50
    Hold=1
    owner():aimEntity():propDelete()   
}



if(A<1&Hold==1&owner():aimEntity()&owner():aimPos():distance(owner():pos())<Di&owner():keyAttack2()){
    owner():soundPlay(1,1,"/items/ammocrate_open.wav")
    A=50
    Hold=0
    Crate2=propSpawn("models/hunter/blocks/cube075x075x075.mdl",holoEntity(1):pos()+vec(0,0,0),ang(90*randint(1,4),90*randint(1,4),90*randint(1,4)),1)  
    Crate2:setMaterial("models/props_wasteland/wood_fence01a")
    Crate2:setColor(vec(255,255,255)*randint(70,100)/100)
}
