moonlyer Posted April 28, 2018 Posted April 28, 2018 (edited) Hi modders, I have a custom Block with two states (for example meta 0, and meta 1). I've created and registered ItemBlock for this Block, just to have both variants in creative for testing. I've also made override of Block.getItemDropped so that my block could drop another item when destroyed. Everything is working fine except for models. I have 2 issues: 1. When my block with meta 1 is destroyed - my item gets dropped with placeholder model (item model that drops from block with meta 0 is fine). I've managed to fix this by adding another line like this: ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory")); ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(item.getRegistryName(),"inventory"));//new line But it feels not right to manually add models to every meta state. Ideally I want to call setCustomModelResourceLocation only once for my Item. How should I fix this? Should I drop my Item in onBlockDestroyedByPlayer instead? 2. Two ItemStacks, that got generated from my ItemBlock, have auto-generated icons in the inventory. I want to change them to custom icons. I guess I should do something with .json files, but I was not able to find the solution. What should my actions be in general if I want to add custom icons to ItemBlock? Edited April 29, 2018 by moonlyer Quote
Draco18s Posted April 28, 2018 Posted April 28, 2018 Blocks that have variants defined by the blockstate json file need to specify their variant string as their model, not "inventory" https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L68-L71 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
moonlyer Posted April 28, 2018 Author Posted April 28, 2018 On 4/28/2018 at 9:37 PM, Draco18s said: Blocks that have variants defined by the blockstate json file need to specify their variant string as their model, not "inventory" https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L68-L71 Expand Yeah, I get that part. That line above refers to the item that only dropped by my block. That item is not my item block. My item block is registered right as you suggest. Quote
Draco18s Posted April 28, 2018 Posted April 28, 2018 On 4/28/2018 at 9:45 PM, moonlyer said: My item block is registered right as you suggest. Expand No, you registered it like this: On 4/28/2018 at 8:58 PM, moonlyer said: ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(item.getRegistryName(),"inventory"));//new line Expand Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
moonlyer Posted April 28, 2018 Author Posted April 28, 2018 On 4/28/2018 at 9:54 PM, Draco18s said: No, you registered it like this: Expand Well there is some misunderstanding. WILD_DUST - my ItemBlock UNREFINED_DUST - my Item that's just referenced in my override of Block.getItemDropped That's how I register my items: public class ElcraftItems { //Item Variables to be registered public static final Item DUST_COIN= new DustCoin(); public static final Item UNREFINED_DUST=new UnrefinedDust(); public static final Item WILD_DUST= new WildDustItemBlock(ElcraftBlocks.WILD_DUST).setRegistryName(ElcraftBlocks.WILD_DUST.getRegistryName()); public static void Register(IForgeRegistry<Item> reg) { ArrayList<Item> itemsToBeInitialized=new ArrayList<Item>(); itemsToBeInitialized.add(DUST_COIN); itemsToBeInitialized.add(WILD_DUST); itemsToBeInitialized.add(UNREFINED_DUST); //Register Items for (Item i:itemsToBeInitialized) { reg.register(i); Elcraft.proxy.registerItemModels(i); } } } @Override public void registerItemModels(Item item) { StateMapperBase b = new DefaultStateMapper(); Block block; try { block=((ItemBlock)item).getBlock(); } catch (ClassCastException x) { block=null; } BlockStateContainer bsc; //If ItemBlock if (block!=null) { //if (item.getHasSubtypes()) //{} bsc = block.getBlockState(); ImmutableList<IBlockState> values = bsc.getValidStates(); for(IBlockState state : values) { String str = b.getPropertyString(state.getProperties()); ModelResourceLocation res = new ModelResourceLocation(item.getRegistryName(), str); //System.out.println(res.getResourcePath()); ModelLoader.setCustomModelResourceLocation(item,block.getMetaFromState(state),res); } } else { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory")); ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(item.getRegistryName(),"inventory")); } } So, do you suggest that i still need to register item model that is completely unrelated to my block with block's variant string? Quote
Draco18s Posted April 28, 2018 Posted April 28, 2018 So WILD_DUST drops UNREFINED_DUST, and when it does so, it's icon is the purple and black cube? Yeah, you dropped it with a metadata of 1 and you registered an icon for metadata of 0. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
moonlyer Posted April 28, 2018 Author Posted April 28, 2018 On 4/28/2018 at 11:06 PM, Draco18s said: So WILD_DUST drops UNREFINED_DUST, and when it does so, it's icon is the purple and black cube? Yeah, you dropped it with a metadata of 1 and you registered an icon for metadata of 0. Expand Right. But the problem is that UNREFINED_DUST is not an ItemBlock and does not have reference to a multistate block. So there's no way I could know every meta that I need to register in registerItemModels other than manually code it. Is there a way to drop UNREFINED_DUST with meta 0 regardless of WILD_DUST meta? Quote
Draco18s Posted April 28, 2018 Posted April 28, 2018 No. You need to change your block class to deal with dropped items correctly. Namely, not return 1 from damageDropped() when dropping the unrefined dust. If you can't handle that, override getDrops() instead 1 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
moonlyer Posted April 29, 2018 Author Posted April 29, 2018 (edited) Thanks. I think I got it. It's really easy to get lost if you don't understand completely how minecraft classes interact with each other. P.S. My second issue (inablility to have different models for Block and it's ItemBlock) was solved by registering ItemBlock with a different registry name, and creating anoter blockstate .json. Previously I used the same registry name for block and ItemBlock. Edited April 29, 2018 by moonlyer 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.