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.

[SOLVED][1.16.4] Get WallTorchBlock that matches TorchBlock/TorchItem

Featured Replies

Posted

in items class we have...

public static final Item TORCH = register(new WallOrFloorItem(Blocks.TORCH, Blocks.WALL_TORCH, (new Item.Properties()).group(ItemGroup.DECORATIONS)));


and in blocks we have...

public static final Block SOUL_TORCH = register("soul_torch", new TorchBlock(AbstractBlock.Properties.create(Material.MISCELLANEOUS).doesNotBlockMovement().zeroHardnessAndResistance().setLightLevel((state) -> {
      return 10;
   }).sound(SoundType.WOOD), ParticleTypes.SOUL_FIRE_FLAME));
   public static final Block SOUL_WALL_TORCH = register("soul_wall_torch", new WallTorchBlock(AbstractBlock.Properties.create(Material.MISCELLANEOUS).doesNotBlockMovement().zeroHardnessAndResistance().setLightLevel((state) -> {
      return 10;
   }).sound(SoundType.WOOD).lootFrom(SOUL_TORCH), ParticleTypes.SOUL_FIRE_FLAME));


So is there any way to get the (Block wallBlockIn) value that is set by WallOrFloorItem through the item or the registry?
It makes sense that if the two are intertwined as they are there should be some way of doing this.

Or should I just start the gymnastic to loop over and pull out using the register names [basically using soul from "soul_torch" to look for "soul_"+wall+"_torch"] to get the correct block.

Of course I could also skip using tags to get my item list and instead make it a config in pairs to get the data in a more reliable and configurable by mod pack developers.

Edited by frakier

  • Author

though of an idea... in my tags json I can do ""minecraft:redstone_wall_torch" and then use Item.getItemFromBlock(blockIn) to get the Item instead of the other way around.
I'll give it a try and report back.

Edited by frakier

  • Author

Solved, that was the answer I made the tags json using the "wall_torch" version of each torch and then use that to get the other information i needed.
 

{
	"replace": false,
	"values": [
		"minecraft:wall_torch",
		"minecraft:redstone_wall_torch",
		"minecraft:soul_wall_torch"
	]
}

Then I was able to get the item using the wall_torch blocks and then from the item I could get the normal torch blocks. Kind of backwards way around but it worked.

Edited by frakier

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.