Jump to content

Recommended Posts

Posted

good nights 
in this specific moment i need to know the exact face of the block the player is looking at when right clock on the costume block 
its for for something im doing whit a custom block right inside this specific method

 

	    // ########## ########## ########## ##########
    // Onright click
    @Override
       public ActionResultType use(BlockState blockstate, World warudo, BlockPos blockpos, PlayerEntity pe, Hand mano, BlockRayTraceResult blkrtraceresult) {
        System.out.println("the player has righ click the block");
        
        int level = blockstate.getValue(LEVEL);
        int deep = blockstate.getValue(DEEP);
        
        if(!warudo.isClientSide) {
	        if(pe.isDiscrete()) {
        }
        
        if(pe.isCrouching()) {            
        }
            
                level ++;
                level = ( level > 15 )? 0 : level;
	                deep --;    
                deep = ( deep < 0 )? 15 : deep;                
            
            blockstate = blockstate.setValue(LEVEL, Integer.valueOf(level));
            blockstate = blockstate.setValue(DEEP, Integer.valueOf(deep));
            
            warudo.setBlock(blockpos, blockstate, 3); //2?
            
            String mensaje = String.format( "Level = %1$s, Deep = %2$s" , level , deep );
            Vector3d target = blkrtraceresult.getLocation();
	//how do i now the side of the block the player has clinked 
	            float factor =  ( 1.0F / 3.0F );
            int hx = (int)(((target.x) %1) / factor);
            int hy = (int)(((target.y) %1) / factor);
            int hz = (int)(((target.z) %1) / factor);
            
            mensaje += " => " + hx + ",  " + hy + ",  " + hz;
            System.out.println(  mensaje );            
            showthis(mensaje, pe);            
            
        }
        
        return ActionResultType.sidedSuccess(warudo.isClientSide);
    }    
	

 

thank for your attention 


 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.