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

    • Electronic Arts is making some much-needed changes to its soccer annual game EAFC 24 Coins. The addition of cross-play between PC, PS5. Stadia as well as Xbox Series X/S gamers and also players from PS4 as well as Xbox One players, is very thrilling. Cross-play has been demanded in FIFA by players for quite a long time. But as exciting as it may be, EA is actually holding off on providing full support for the technology. Particularly, FC 24 is not offering cross-play in its well-known Pro Clubs game mode. A confirmed statement from EA has stated that FC 24's cross-play feature will not be available for Pro Clubs in the foreseeable time. The reason according to EA is to ensure that "product innovativeness is of high top quality." Furthermore, Pro Clubs, according to EA is a degree of technical complexity that is higher than what developers can handle at the moment. "Technical complexity" is a subtle method of describing the scenario. The Pro Clubs of FIFA permit the use of up to 22 players in an online multiplayer game that includes between 2 and 11 real players in each team. Connecting 22 players on one platform isn't a simple task and adding interplay of the four platforms can make difficult. In the real world, the platforms pose less complicated than 22 players, however EA is just exploring cross-play, and therefore it's plausible when they say that additional time is required. It isn't stopping FIFA fans from feeling dissatisfied and angry about the situation However. Demands for cross-play being made available to FC 24 Pro Clubs are being circulated across the web and FIFA YouTuber JCC encouraging players to join support the cause. JCC along with other well-known players within the FIFA community are complaining that EA of placing the importance of FIFA Ultimate Team above the core experience like Pro Clubs. The company is very grateful that it has responded to the growing discontent within members of the FIFA community, saying it is aware of the criticism. Electronic Arts then points to its FIFA Twitter account to receive future updates on its plans for future games. This isn't a guarantee at all but it's about the closest a game's creator can get to say that something is being developed. FC 24 is all but certain to not have cross-play features for Pro Clubs at launch, or during the game's release. Maybe Pro Club cross-play will end being tested in FC 24 similar to how the basic cross-play was implemented in cheap EAFC 24 Coins. More likely, the feature will be a bit further away to be released by EA Sports FC's launch in 2023 or even later. It's also possible that FIFA fans are right and that EA's priority lies in FUT. It's the responsibility of EA to prove the criticism is not true.
    • SENSA69 💯 Daftar Link Slot Gacor Hari Ini Bisa Judi Slot Online KLIK DISINI >>> DAFTAR DAN LOGIN KLIK DISINI >>>   DAFTAR AKUN GACOR KLIK DISINI >>> DAFTAR AKUN VVIP KLIK DISINI >>>  LINK ALTERNATIF KLIK DISINI >>> AKUN GACOR SCATTER HITAM SENSA69 adalah slot gacor winrate 100% dengan server thailand dan akun pro. Dapatkan akses menuju kemenangan ke puluhan sampai ratusan juta rupiah hanya dalam hitungan menit. 3 web yang kami hadirkan ini adalah yang terbaik dengan histori kemenangan tertinggi di satu Asia Tenggara. Member-member dari web ini selalu kembali karena tim admin dan CS yang profesional serta kemenangan berapapun pasti akan dibayar. RTP slot gacor juga sudah disiapkan agar kalian tidak bingung lagi mau main apa dan di jam berapa. Semua fasilitas seperti deposit dana dan pulsa sudah disiapkan juga untuk kemudahan para slotters. Jadi tunggu apalagi? Raih kemenangan kalian disini sekarang juga!
    • SV388: Temukan situs taruhan sabung ayam resmi yang terjamin aman di Winning303! Bergabunglah dengan SV388 untuk pengalaman taruhan sabung ayam yang mengasyikkan dan aman. Nikmati berbagai pertandingan sabung ayam terbaik sambil memanfaatkan layanan terpercaya dari Winning303. Daftar sekarang dan rasakan sensasi taruhan yang tak terlupakan dengan SV388 di Winning303! ❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ ❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰
    • MPO1121: Temukan daftar situs judi slot dengan layanan pembayaran melalui Bank Danamon. Bergabunglah dengan MPO1121 untuk pengalaman taruhan slot online yang menarik dan aman. Nikmati berbagai permainan slot terbaik sambil memanfaatkan kemudahan pembayaran melalui Bank Danamon. Daftar sekarang dan rasakan sensasi taruhan yang tak terlupakan dengan MPO1121!" ❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ ❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰
  • Topics

×
×
  • Create New...

Important Information

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