Posted March 22, 20169 yr This is what I see in my log: [18:29:39] [server thread/INFO] [FML/]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@17eb9432) [18:29:39] [server thread/INFO] [FML/]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@17eb9432) [18:29:39] [server thread/INFO] [lidr/]: Registering Draftable :test [18:29:39] [server thread/INFO] [FML/]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@17eb9432) [18:29:39] [server thread/INFO] [lidr/]: Registering Draftable :test [18:29:39] [server thread/INFO] [lidr/]: Registering Draftable :test This is my event handler: @SubscribeEvent public void worldLoad(WorldEvent.Load e){ if(!e.world.isRemote) { DraftableMap dMap = new DraftableMap(); dMap.AddPart("0,0,0", new EdgePart(LuxinReg.RegisteredLuxin.get("Blue"), Purity.Base)); DraftableReg.RegisterDraftable(CoreFactory.GenerateFrom("test", CoreType.Sword, dMap)); //Testing items } } and this is my registerDraftable method public static void RegisterDraftable(IDraftable draftable){ LogHelper.info("Registering Draftable :" + draftable.GetName()); knowledgeBase.put(draftable.GetName(), draftable); } This is happening when I run through eclipse and play in an smp world, any ideas? So I'm dumb, this event is obviously getting triggered for each dimension. Revised question, I am looking for an event that happens once when you launch an smp world or when a server is starting its world so I can check if the world is remote. What event should I be using here? Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 23, 20169 yr Checking if the world is remote (which would mean it's the CLIENT world, btw), is not really a goal, it is a means to something else. So, what exactly are you trying to do? If you want to add data to the world, use WorldSavedData. If you want to add structures or something like that, look into IWorldGenerator (if that's still a thing) or the various generation events such as PopulateChunkEvent.Post. http://i.imgur.com/NdrFdld.png[/img]
March 23, 20169 yr Author The IDraftable that you can see me adding to a hashmap is a structure that I use to create an NBT based item (think tinkers but many more parts) I already have all the communication lines for giving an item to a player and syncing the nbt items between server and client. I am just trying to prime the world with a test item so I can test my save/load/item creation/item rendering methods. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 23, 20169 yr And where will this Item be located? Are you giving it to the player when they join? Use PlayerLoggedInEvent. Are you placing it in a chest somewhere? Use the ChestGenHooks or loot tables or whatever that has become to add it to random loot or use one of the world gen events to place it yourself. Or are you doing something else entirely? I don't see what the problem is that you're trying to solve. http://i.imgur.com/NdrFdld.png[/img]
March 23, 20169 yr Author It isn't really a problem for this purpose but for future reference I am trying to figure out what events I can use for initializing different things when a world starts up. In this particular case the NBT information is getting stored in a custom registry that can be added to at any point during the game (I want to add a test item when the world starts). Each user has a selected item that will get created and given to them on a hotkey press. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 23, 20169 yr Then I would store that information as additional data attached to those players, i.e. each player stores information about the Item(s) they can create. Use IExtendedEntityProperties (pre 1.8.9) or the Capabilities system (1.8.9+). Or is the registry global for all players? In any case, world start up isn't the place I would choose to do this - unless you really need access to the World object for some reason (e.g. time of day), I would do it during the FML init or postInit phase, after all my items were registered. http://i.imgur.com/NdrFdld.png[/img]
March 23, 20169 yr Author I do need the world object because this also generates a bakedModel if it is on the client side and the registry is global but the selection is per user. I already have capabilities set up for the user specific things. I just don't have the system in place for designing the items yet, so in order to test other things I need to prime the registry with an item. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 23, 20169 yr You don't need a World object to generate/register baked models - that should be done through your ClientProxy during FML's pre-init phase after registering your items. And if for whatever reason you DO need the World object for your baked model (which you shouldn't), since you are doing this in your ClientProxy you can use Minecraft.getMinecraft().theWorld, BUT, I don't recommend that as it might very well be in an invalid state at that point (e.g. not existing yet). You can always access it from within your baked model class at the time of rendering. http://i.imgur.com/NdrFdld.png[/img]
March 23, 20169 yr Author When I register the nbt items (if it is client side) I generate a bakedModel from the nbt information and that can't happen on server side because the class bakedModel doesn't exist serverside. New items can be designed and added to the registry during run-time. Which means that the items available are determined by the server during run-time not during initialization. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 23, 20169 yr Author Well this topic has gotten quite off course. I'm just looking for events that I can use that only occur once when a world is starting up. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 23, 20169 yr Author There is really no event that only happens once??? To be clear I mean once in the sense that it would only get called when a server is starting up, I do not mean once per world. I'm pretty sure it just seems like I'm doing this the wrong way because this thread is a bunch of half explanations. But I would like to find out sooner rather than later if I really am doing something wrong. So can you clarify what part you think I am doing wrong and I will give a full explanation of how I am doing that part to see if I actually am wrong. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 24, 20169 yr Author I am using this: public class DraftableSmartItemModel implements ISmartItemModel{ @Override public IFlexibleBakedModel handleItemState(ItemStack stack) { IFlexibleBakedModel model = null; if(stack.getTagCompound().hasKey(Refs.DRAFTABLE) && DraftableReg.Exists(stack.getTagCompound().getString(Refs.DRAFTABLE))) model = DraftableReg.getModel(stack.getTagCompound().getString(Refs.DRAFTABLE)); return model; } } I generate the model for each item once, when they get added to my registry public class DraftableReg { public static void RegisterDraftable(IDraftable draftable){ models.put(draftable.GetName(), new DraftableBakedModel(draftable)); LogHelper.info("Registering Draftable :" + draftable.GetName()); knowledgeBase.put(draftable.GetName(), draftable); } } public class DraftableBakedModel implements IFlexibleBakedModel{ private List<BakedQuad> quads = new ArrayList<BakedQuad>(); public DraftableBakedModel(IDraftable draft){ DraftableMap parts = draft.GetPartArray(); for(int xPos = 0; xPos < 16; xPos++){ for(int yPos = 0; yPos < 16; yPos++){ for(int zPos = 0; zPos < 16; zPos++){ if(parts.GetPart(xPos + "," + yPos + "," + zPos) != null) quads.addAll(getQuadFrom(parts.GetPart(xPos + "," + yPos + "," + zPos), xPos, yPos, zPos)); } } } } private List<BakedQuad> getQuadFrom(IPartType getPart, int x, int y, int z) { List<BakedQuad> list = new ArrayList<BakedQuad>(); BakedQuad quad; //North quad = new BakedQuad(applyOffset(getPart.GetVertices(EnumFacing.NORTH),x,y,z), 0, EnumFacing.NORTH); list.add(quad); //Up quad = new BakedQuad(getPart.GetVertices(EnumFacing.UP), z, EnumFacing.UP); list.add(quad); //East quad = new BakedQuad(getPart.GetVertices(EnumFacing.EAST), z, EnumFacing.EAST); list.add(quad); //South quad = new BakedQuad(getPart.GetVertices(EnumFacing.SOUTH), z, EnumFacing.SOUTH); list.add(quad); //Down quad = new BakedQuad(getPart.GetVertices(EnumFacing.DOWN), z, EnumFacing.DOWN); list.add(quad); //West quad = new BakedQuad(getPart.GetVertices(EnumFacing.WEST), z, EnumFacing.WEST); list.add(quad); return list; } private int[] applyOffset(int[] vertices, int x, int y, int z) { for(int i = 0; i < 7; i++)//7 elements per vertex { for(int j = 1; j < 5; j++)// 4 vertices { switch(i){ case 0: vertices[i*j] = vertices[i*j] + (x*Refs.OFFSET);//xpos break; case 1: vertices[i*j] = vertices[i*j] + (y*Refs.OFFSET);//ypos break; case 2: vertices[i*j] = vertices[i*j] + (z*Refs.OFFSET);//zpos break; default: break; } } } return vertices; } } I'm not completely done with it but this is most of the code relevant to my model generation. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
March 24, 20169 yr Author Like I said this thread was getting very off topic. I was trying to register a test item when the world loads and I noticed that it was registering the item 3 times in the event I was using. It is not a problem for this particular case but I am curious what events are available that are only triggered once during the startup process and are after postInit. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
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.