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.20.4] BlockState check of what this block its made of wood|stone|dirt

Featured Replies

Posted

im following this case coze removing the material class from the code fucks up mi items that depends on it 
i need to find a replacement for the Material class

 

this is an old item from back 1.8 

 

when turn on hold right click it checks the target block and if its made of wood it changes to cutting animation 

Material pmat = blkstate.getMaterial();

     if (pmat == Material.WOOD){

//then cut it down 

}

this other one checks for dirt or stone its no supposed to work on metal or wood 

 

 

what i could use ? 

 

 

9 hours ago, perromercenary00 said:

what i could use ? 

You could use the BlockTags.MINEABLE_WITH_AXE tag.

  • Author

sorry for the stuborn ness ss

 

test code

Spoiler

				
			if (!warudo.isClientSide && rp != null && can_do_it(helditem)) {
		dblkstate = rp.getBlockState();
		
		String nnn = ForgeRegistries.BLOCKS.getKey(dblkstate.getBlock()).toString();
		System.out.println("\n");
		System.out.println("name " + nnn);
		
		if (dblkstate.canBeReplaced()) {
		System.out.println("blkstate.canBeReplaced()");
		}
		
		if (dblkstate.is(BlockTags.MINEABLE_WITH_AXE)) {
		System.out.println("BlockTags.MINEABLE_WITH_AXE");
		}
		
		if (dblkstate.is(BlockTags.MINEABLE_WITH_PICKAXE)) {
		System.out.println("BlockTags.MINEABLE_WITH_PICKAXE");
		}
		
		if (dblkstate.is(BlockTags.MINEABLE_WITH_SHOVEL)) {
		System.out.println("BlockTags.MINEABLE_WITH_SHOVEL");
		}
		
		if (dblkstate.is(BlockTags.MINEABLE_WITH_HOE)) {
		System.out.println("BlockTags.MINEABLE_WITH_HOE");
		}
		
		
		}				
			


name minecraft:grass_block
BlockTags.MINEABLE_WITH_SHOVEL


name minecraft:dirt
BlockTags.MINEABLE_WITH_SHOVEL

name minecraft:oak_log
BlockTags.LOGS


name minecraft:oak_planks
BlockTags.PLANKS

name minecraft:oak_leaves
BlockTags.MINEABLE_WITH_HOE

name minecraft:cobblestone_slab
BlockTags.MINEABLE_WITH_PICKAXE

name minecraft:stone
BlockTags.MINEABLE_WITH_PICKAXE


name minecraft:coal_block
BlockTags.MINEABLE_WITH_PICKAXE

logs and planks return nothing on minable but i can use the other tags 

name minecraft:oak_log
BlockTags.LOGS

name minecraft:oak_planks
BlockTags.PLANKS

 

it kinda works but its not like like perfect 

 

 

 

 

 

 

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.