Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] spawning second custom block in place whit same facing once the first one gets breaked by player whit or whitout


Recommended Posts

Sorry for spawning so much question so fast but im trying to update mi blocks from 1.12 and many things has changed 

twoblocks.png

 

the left transparent block is the default
this block when breaken must be replaced by the right opaque one 
surprize old code from 1.12 dont works here now there's context and new stuff about


* first question the function is giving meg the blockstate from the breaking block Mblocks.GLASS_MESH_PANE  "BlockState blkstate" how do i extract the value of FACING from it 
* second, mi custom block from mi custom blockClass Mblocks.GLASS_MESH_PANE_BROKE 
     how i do call that block inside the code and apply to it the FACING from the breaking block

* third how i  "world.setBlock()" mi block whit the right facing blockstate value ?
  

 

 



	    // ########## ########## ########## ##########
	       public void playerDestroy(World warudo, PlayerEntity pe, BlockPos blockpos, BlockState blkstate, @Nullable TileEntity p_180657_5_, ItemStack itemstack) {
          pe.awardStat(Stats.BLOCK_MINED.get(this));
          pe.causeFoodExhaustion(0.005F);
          
	          if(!warudo.isClientSide) {
              
              Block replace_block = Mblocks.GLASS_MESH_PANE_BROKE.get(); //?
              
              Facing fdirection =  //¿?
              
              BlockState repstate = replace_block.BLOCK_STATE_REGISTRY 
                            
              warudo.setBlock(blockpos, blkstate, 0);//??
              
          }
          
          
          /*
          public void setPlacedBy(World p_180633_1_, BlockPos p_180633_2_, BlockState p_180633_3_, LivingEntity p_180633_4_, ItemStack p_180633_5_) {
              p_180633_1_.setBlock(p_180633_2_.above(), p_180633_3_.setValue(HALF, DoubleBlockHalf.UPPER), 3);
           }          
                    
          public boolean emptyBucket(@Nullable PlayerEntity p_180616_1_, World p_180616_2_, BlockPos p_180616_3_, @Nullable BlockRayTraceResult p_180616_4_) {
	          if (!p_180616_2_.setBlock(p_180616_3_, this.content.defaultFluidState().createLegacyBlock(), 11) && !blockstate.getFluidState().isSource()) {
            */  
              
          System.out.println("playerDestroy");
          
          dropResources(blkstate, warudo, blockpos, p_180657_5_, pe, itemstack);
       }
    



thank for your attention

Link to comment
Share on other sites

The facing is one of the block properties that determine the state. e.g. something like

    	block.defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.NORTH);

I guess you would copy the block properties from the block state you replaced?

Edited by warjort
Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

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