Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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.

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.