Jump to content

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


perromercenary00

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

I think you are missing an

event.setCanceled(true);

Otherwise you are going to change the block in that location and then its just going to destroy it anyway.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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