Posted March 10, 20169 yr An implementation of IItem is used to generate an NBTTagCompound for an item, but the item only stores the generated information instead of all the information involved in the generation. I am doing it this way because the ModelMap will have a LOT of information and storing that information in every item is a massive waste of space. This is the class structure/ information that I need to store: Class Names were changed to simplify the example None of the implementation classes will have more significant information than what is given. public class ItemExample implements IItem{ private ModelMap map; private String name; } public class ModelMap { private HashMap<Coord, IPartType> map; } public class Coord { private int x,y,z; } public class PartExample implements IPartType { private String name; private Purity purity; } public Enum Purity{ } Is using a Json file a good way of going about this? Is there a convention for doing something like this that I am just unaware of? Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 11, 20169 yr Author Restructured and Rephrased question so that it will make more sense and be easier to understand what I need. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 11, 20169 yr I really hope that you understand difference between Item - which is singleton ("description of what you are holding") and ItemStack ("the thing that is actually there"). Now if you know that I really hope you considered the fact that making and registering Item instances should happen in preInit of MOD, which is game load. It is possible to not do it that way, but that introduces you to more problems. 1. Client will have to load server's Item singletons somehow - and I mean again - doing so NOT in preInit() of game (which happens waaay before even joining a server) will again introduce you to client sided problems - mainly rendering systems and registry-to-renderers compatibility. 2. Without even looking at client (which is one of biggest problems, since Vanilla/Forge is not designed to handle it), you will have corrupted data, useless packets "leaks" and who knows what when it comes to: * Loading world (ItemStacks are loaded based on Item registry) - which will totally corrupt everything you have with possible slightest change to your (i think) Json-generated items. * Syncing client - kinda 1st point - if server sends data about item which client doesn't have, it will not go well (pretty bad). That is all ofc. if I an understanding correctly what you are after. As to direct response to questions: If not in ItemStack or Entity, you can store data in WorldSavedData (note that save/load is on-demand) or any self-made system (you could maybe utilize Capability system, but idk). So yeah - Json can be fine if you don't want e.g NBT (WorldSavedData). As to how it should be made: Everything should be saved to ItemStack. If you really have a lot of data - you can easily wrap it up in short namings or ID system that can be stored in mentioned WorldSaveData and synced to client on logging in. Seriously, MC can handle quite some data in ItemStacks (I was once sending textures inside ItemStack, about MC 1.4-1.5). 1.7.10 is no longer supported by forge, you are on your own.
March 11, 20169 yr Author The example I gave is a little misleading with the names, I simplified everything down to the just the raw information I need to store. I have TypeCores(Melee, Mining, Ranged. etc) that extend Item and get registered during prInit() normally. I have a factory that knows how to generate an IBakedModel and relevant NBTTagCompound from this information and return that as an ItemStack for the appropriate TypeCore. I preform the generation after the item has been designed/or a design was altered and uses copies of that to create ItemStack instances. I am not doing the generation each time an ItemStack is created. This question is purely about how best to store the information and if there is an existing convention that people use, what is it? Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 11, 20169 yr As to direct response to questions: If not in ItemStack or Entity, you can store data in WorldSavedData (note that save/load is on-demand) or any self-made system (you could maybe utilize Capability system, but idk). So yeah - Json can be fine if you don't want e.g NBT (WorldSavedData). 1.7.10 is no longer supported by forge, you are on your own.
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.