perromercenary00 Posted May 21, 2023 Posted May 21, 2023 (edited) i need some headstorm here 1.19.4 change the way to add the items and blocks to custome mod tabs now you have to use an event an manually add every item or block and thas a pain in <t> coze i have to many blocks soo i tell to miself what if i use a foor loop whith "DeferredRegister<Item> ITEMS" thing and it works it drops everything into the tab and i dont have to manually keep track of it if change something Reveal hidden contents //agregar items y block a las tabs private void addCreative(CreativeModeTabEvent.BuildContents event) { Item actualItem = null; Block actualBlock = null; int count = 0; if( event.getTab() == tab.MERCBLKTAB ){ for ( RegistryObject<Item> ResourceKey : ItemInit.ITEMS.getEntries()) { actualItem = ResourceKey.get(); if(!(actualBlock instanceof trampilla)) { event.accept(actualItem); } count++; } } } but i have some blocks and some items that are kinda metablocks/subitems basically the same block thing and i dont nedd/want them to be visible i try to filter them by class but dint works coze in this stage they are already converted to item block soo i cannot filter using instance of if(!(actualBlock instanceof trampilla)) { event.accept(actualBlock); } Sooo any idea how i can mark this items blocks to be excluded from the tab Edited May 22, 2023 by perromercenary00 Solved Quote
warjort Posted May 21, 2023 Posted May 21, 2023 Is your "actualItem" a BlockItem? Then see Block.byItem() Otherwise we can't help you without more information. If you want help, you need to post a project on github that reproduces your problem. Incomplete information posted in the forums will likely just mean your question gets ignored. Quote 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.
warjort Posted May 21, 2023 Posted May 21, 2023 (edited) You also know you can have different DeferredRegisters for different internal categories of your items? e.g. psuedo code: // Real items that should be shown in creative tabs public static final DeferredRegister<Item> REAL_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Item> TEST = REAL_ITEMS.register("test", () -> new Item(new Item.Properties())); // Internal items the user shouldn't have direct access to public static final DeferredRegister<Item> META_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Item> META = META_ITEMS.register("meta", () -> new Item(new Item.Properties())); Edited May 21, 2023 by warjort Quote 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.
perromercenary00 Posted May 22, 2023 Author Posted May 22, 2023 ya it makes sense itemblock is a subclass of item and from itemblock the block can be retrieved Reveal hidden contents //agregar items y block a las tabs private void addCreative(CreativeModeTabEvent.BuildContents event) { Item actualItem = null; Block actualBlock = null; int count = 0; boolean RegistrarEste = false; if( event.getTab() == tab.MERCBLKTAB ){ for ( RegistryObject<Item> ResourceKey : ItemInit.ITEMS.getEntries()) { RegistrarEste = true; actualItem = ResourceKey.get(); if((actualItem instanceof BlockItem)) { BlockItem actualBlockItem = (BlockItem)actualItem; if(actualBlockItem.getBlock() instanceof trampilla) {//ignore all the trampillas RegistrarEste = false; } } if(RegistrarEste) { event.accept(actualItem); } count++; } } } Thanks for your help again Quote
Recommended Posts
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.