Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.13.2] ItemBlocks do not render in creative inventory #5470

Closed
drekryan opened this issue Feb 15, 2019 · 4 comments · Fixed by #5483
Closed

[1.13.2] ItemBlocks do not render in creative inventory #5470

drekryan opened this issue Feb 15, 2019 · 4 comments · Fixed by #5483
Labels
1.13 Bug This request reports or fixes a new or existing bug.

Comments

@drekryan
Copy link

drekryan commented Feb 15, 2019

ExampleMod: https://github.com/drekryan/ExampleMod
Note: Everything is setup in the ExampleMod provided in the link above, just git clone and run. It registers a Block, slab, and stair which all have the issue as well as provides an ItemGroup.

Brief Description:
Registered ItemBlocks are not rendering or displaying tooltips in the creative inventory or item group tabs. This does not appear to affect regular Items, just ItemBlocks.

Steps to Reproduce:

  1. Create a basic mod with Block and Item registry events hooked up
  2. Create a new Block in the Block Registry Event blockRegistryEvent.getRegistry().registerAll( altar_stone = new Block( Block.Properties.create( Material.ROCK ) ).setRegistryName( "examplemod", "altar_stone" ) );
  3. Create an appropriate blockstate, model, and texture for the block (I used the cube_all model and a texture but a texture may not even be needed as a missing texture should appear)
  4. Create an ItemBlock for the Block in the Item Registry event itemRegistryEvent.getRegistry().registerAll( new ItemBlock( altar_stone, new Item.Properties() ).setRegistryName( "examplemod", altar_stone.getRegistryName().toString() ) );

What I expected to happen:
I expected the item block to appear in the all items tab of the creative inventory with proper rendering and tooltip. Also assigning an ItemGroup to the item I also expect it to appear in the ItemGroup tab.

What happened:
The ItemBlock was properly registered. I can use .give to get the item and hold it in my inventory but I can not obtain it from the creative inventory or see it rendered.

Versions:
Minecraft: 1.13.2
Forge: 25.0.9

2019-02-15_04 25 13
2019-02-15_04 25 27
2019-02-15_04 25 40

@SquidDev
Copy link
Contributor

SquidDev commented Feb 15, 2019

So it appears the patch to redirect Item.BLOCK_TO_ITEM to Forge's registry was dropped (ca72710#diff-d0164446501bbeeb653e67a161393d00L12), meaning that the BLOCK_TO_ITEM map is never updated with modded blocks, and so new ItemStack(someBlock) returns air instead.

I'm happy to put a PR together if desired?

@drekryan
Copy link
Author

Thanks for looking into this issue!

@tterrag1098 tterrag1098 added Bug This request reports or fixes a new or existing bug. Superseded This request has a more updated, more capable, and overall better alternative. 1.13 and removed Superseded This request has a more updated, more capable, and overall better alternative. labels Feb 15, 2019
@LordMonoxide
Copy link
Contributor

As a temporary fix you can add this to your block class:

  //TODO: remove this once the forge registry is fixed
  @Override
  public Item asItem() {
    return ForgeRegistries.ITEMS.getValue(this.getRegistryName());
  }

Note: my ItemBlocks are registered with the same registry name as the Block they belong to. You may have to change this.getRegistryName() to whatever name you used to register the ItemBlock.

@drekryan
Copy link
Author

As of 25.0.20 and PR #5483, this issue has been resolved. Closing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.13 Bug This request reports or fixes a new or existing bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants