Jump to content

WorldEvent.Load called 3 times?


UberAffe

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Dalam dunia perjudian online yang berkembang pesat, mencari platform yang dapat memberikan kemenangan maksimal dan hasil terbaik adalah impian setiap penjudi. OLXTOTO, dengan bangga, mempersembahkan dirinya sebagai jawaban atas pencarian itu. Sebagai platform terbesar untuk kemenangan maksimal dan hasil optimal, OLXTOTO telah menciptakan gelombang besar di komunitas perjudian online. Satu dari banyak keunggulan yang dimiliki OLXTOTO adalah koleksi permainan yang luas dan beragam. Dari togel hingga slot online, dari live casino hingga permainan kartu klasik, OLXTOTO memiliki sesuatu untuk setiap pemain. Dibangun dengan teknologi terkini dan dikembangkan oleh para ahli industri, setiap permainan di platform ini dirancang untuk memberikan pengalaman yang tak tertandingi bagi para penjudi. Namun, keunggulan OLXTOTO tidak hanya terletak pada variasi permainan yang mereka tawarkan. Mereka juga menonjol karena komitmen mereka terhadap keamanan dan keadilan. Dengan sistem keamanan tingkat tinggi dan proses audit yang ketat, OLXTOTO memastikan bahwa setiap putaran permainan berjalan dengan adil dan transparan. Para pemain dapat merasa aman dan yakin bahwa pengalaman berjudi mereka di OLXTOTO tidak akan terganggu oleh masalah keamanan atau keadilan. Tak hanya itu, OLXTOTO juga terkenal karena layanan pelanggan yang luar biasa. Tim dukungan mereka selalu siap sedia untuk membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan respon cepat dan solusi yang efisien, OLXTOTO memastikan bahwa pengalaman berjudi para pemain tetap mulus dan menyenangkan. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi pilihan utama bagi jutaan penjudi online di seluruh dunia. Jika Anda mencari platform yang dapat memberikan kemenangan maksimal dan hasil optimal, tidak perlu mencari lebih jauh dari OLXTOTO. Bergabunglah dengan OLXTOTO hari ini dan mulailah petualangan Anda menuju kemenangan besar dan hasil terbaik!
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa Di dunia perjudian online yang begitu kompetitif, mencari platform yang dapat memberikan kemenangan maksimal (Maxwin) dan hasil terbaik (Gacor) adalah prioritas bagi para penjudi yang cerdas. Dalam upaya ini, OLXTOTO telah muncul sebagai pemain kunci yang mengubah lanskap perjudian online dengan menawarkan pengalaman tanpa tandingan.     Sejak diluncurkan, OLXTOTO telah menjadi sorotan industri perjudian online. Dikenal sebagai "Platform Maxwin dan Gacor Terbesar Sepanjang Masa", OLXTOTO telah menarik perhatian pemain dari seluruh dunia dengan reputasinya yang solid dan kinerja yang luar biasa. Salah satu fitur utama yang membedakan OLXTOTO dari pesaingnya adalah komitmen mereka untuk memberikan pengalaman berjudi yang unik dan memuaskan. Dengan koleksi game yang luas dan beragam, termasuk togel, slot online, live casino, dan banyak lagi, OLXTOTO menawarkan sesuatu untuk semua orang. Dibangun dengan teknologi terkini dan didukung oleh tim ahli yang berdedikasi, platform ini memastikan bahwa setiap pengalaman berjudi di OLXTOTO tidak hanya menghibur, tetapi juga menguntungkan. Namun, keunggulan OLXTOTO tidak hanya terletak pada permainan yang mereka tawarkan. Mereka juga terkenal karena keamanan dan keadilan yang mereka berikan kepada para pemain mereka. Dengan sistem keamanan tingkat tinggi dan audit rutin yang dilakukan oleh otoritas regulasi independen, para pemain dapat yakin bahwa setiap putaran permainan di OLXTOTO adalah adil dan transparan. Tidak hanya itu, OLXTOTO juga dikenal karena layanan pelanggan yang luar biasa. Dengan tim dukungan yang ramah dan responsif, para pemain dapat yakin bahwa setiap pertanyaan atau masalah mereka akan ditangani dengan cepat dan efisien. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi platform pilihan bagi para penjudi online yang mencari kemenangan maksimal dan hasil terbaik. Jadi, jika Anda ingin bergabung dengan jutaan pemain yang telah merasakan keajaiban OLXTOTO, jangan ragu untuk mendaftar dan mulai bermain hari ini!  
    • OLXTOTO adalah bandar slot yang terkenal dan terpercaya di Indonesia. Mereka menawarkan berbagai jenis permainan slot yang menarik dan menghibur. Dengan tampilan yang menarik dan grafis yang berkualitas tinggi, pemain akan merasa seperti berada di kasino sungguhan. OLXTOTO juga menyediakan layanan pelanggan yang ramah dan responsif, siap membantu pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Daftar =  https://surkale.me/Olxtotodotcom1
    • DAFTAR & LOGIN BIGO4D   Bigo4D adalah situs slot online yang populer dan menarik perhatian banyak pemain slot di Indonesia. Dengan berbagai game slot yang unik dan menarik, Bigo4D menjadi tempat yang ideal untuk pemula dan pahlawan slot yang berpengalaman. Dalam artikel ini, kami akan membahas tentang Bigo4D sebagai situs slot terbesar dan menarik yang saat ini banyak dijajaki oleh pemain slot online.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.