I need a code in which my player when it hits an object called a block, the actor can not get through


import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class mario extends Actor { int vf=0,vi=0,b=0, i=0, c=0,x=0,cont=0,count=0,conti=0; boolean derecha = false ; boolean izquierda = false; boolean vas = true; boolean detect = false; boolean dir = false; public double salto() { vf=vi-10*2; return vf; } public void act() { if(Greenfoot.isKeyDown("right")) { setLocation(getX()+4, getY()); c=1; detect = false; dir = true; } if(Greenfoot.isKeyDown("left")) { setLocation(getX()-4, getY()); b=1; detect = true ; dir = false; } if(c==1) { i++; setImage("m"+i+".png"); } if(i==2) { i=0; c=0; setImage("m0.png"); } if(b==1) { x++; setImage("a"+x+".png"); } if(x==2) { x=0; b=0; setImage("a0.png"); } if (Greenfoot.isKeyDown("up")) { derecha = true; izquierda = true; } if (derecha==true && dir== true) { vi++; salto(); setLocation(getX()+3,getY()+vf); setImage("j1.png"); } if(detect==true && dir==false && izquierda==true) { vi++; salto(); setLocation(getX()-3,getY()+vf); setImage("j2.png"); } if(getY()>=355) { count++; if(derecha==true) { setImage("m0.png"); } if( detect==true) { setImage("a0.png"); } detect=false; derecha=false; izquierda=false; vi=0; vas= false; if(Greenfoot.isKeyDown("right")) { setImage("m"+i+".png"); } if(Greenfoot.isKeyDown("left")) { setImage("a"+x+".png"); } } if(vas==true) { if (Greenfoot.isKeyDown("up")) { derecha = true; izquierda = true; } if (derecha==true) { vi++; salto(); setLocation(getX()+3,getY()+vf); } } if(vas==false) { cont++; if(cont==3) { vas=true; } } if(Greenfoot.isKeyDown("space")) { if (derecha==true) { conti=0; int a=getRotation(); getWorld().addObject(new bala(a),getX(),getY()); } if (derecha==false) { conti=0; int a=getRotation(); getWorld().addObject(new bala2(a),getX(),getY()); } } if(getOneIntersectingObject(chompi.class)!=null) { getWorld().addObject(new lose(),269,221); Greenfoot.stop(); } } }