squirrel_killer Posted April 4, 2016 Posted April 4, 2016 So I am am suffering from either a sever case of just stupid, or you use it if you don't use it. I am hoping the latter. I haven't touched Java in maybe 6 or so months, but last time I did was to create a simple minecraft mod to rebalance the game as I wanted. I am in the process of recreating and rebalancing said mod and just tidying it all up as I am planning on using it in a more modern pack and figured I would release to the public this time around. Now last time I did all this was in the early days of 1.8, so I assumed that the old way to add an item was mostly the same, and so I did this: package com.squirrelkiller.utilities.init; import com.squirrelkiller.utilities.Reference; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModItems { public static Item bedding; public static Item bed_frame; public static void init() { bedding = new Item().setUnlocalizedName("bedding"); bed_frame = new Item().setUnlocalizedName("bed_frame"); } public static void registerModItem() { GameRegistry.registerItem(bedding, bedding.getUnlocalizedName().substring(5)); GameRegistry.registerItem(bed_frame, bed_frame.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(bed_frame); registerRender(bedding); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } } Well this actually turns out to now be wrong, and it suggests that I use IForgeRegistry. Well it turns out I am just stupid as I am staring blankly at this basically drooling like an idiot trying to figure out how exactly to use this newer method. I am reading the Javadoc for it and I can tell it will make my life so much easier, but I think I am just over thinking it, can someone just show me how this works. I know this is stupid, but I feel like I am just stupid right now and forgetting how to java. Quote
Choonster Posted April 4, 2016 Posted April 4, 2016 Item implements IForgeRegistryEntry , as do most other singleton classes stored in registries (e.g. Block , BiomeGenBase , Enchantment ). Instead of specifying the registry name in the GameRegistry.registerItem call, set the registry name using IForgeRegistryEntry#setRegistryName (or one of the overloads provided by the Impl subclass) and then register it using the single-argument overload of GameRegistry.register . Don't use unlocalised names to determine the registry names, the whole point of the original implementation of the registry name methods in 1.8.9 was to stop people doing that. You can see how I register items in my mod here. Most of my items use ItemTestMod3.setItemName to set their registry and unlocalised names, but some have completely separate names (e.g. records) that they set manually. Don't use unlocalised names for model locations, the default model loaded for an Item is specified by its registry name. Don't use ItemModelMesher#register to register models, use ModelLoader.setCustomModelResourceLocation or ModelLoader.setCustomMeshDefinition in preInit. I would advise against registering client-only things like models in the same class as you register common things like Item s. I recommend creating a separate class to handle model registration, like this one. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
needoriginalname Posted April 18, 2016 Posted April 18, 2016 Excuse me for bumping up and old post. But How does one register for an item with subtypes, I have a mod that I that will have a few hundred items in its subtype, each with its own unlocalized name for the Language Translation Quote
Choonster Posted April 18, 2016 Posted April 18, 2016 Excuse me for bumping up and old post. But How does one register for an item with subtypes, I have a mod that I that will have a few hundred items in its subtype, each with its own unlocalized name for the Language Translation That hasn't changed in 1.9 and has little to do with the new registry system, since every Item is registered in the same way. Override Item#getUnlocalizedName(ItemStack) to return the appropriate unlocalised name based on any aspect of the ItemStack (stack size, metadata, NBT, capabilities). Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
needoriginalname Posted April 18, 2016 Posted April 18, 2016 Thank you. ... How does one make a thank you post? (EDIT: nvm, found it) 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.