Skip to content

fix npc not spawning - #171

Closed
Controllerdestiny wants to merge 2 commits into
SignatureBeef:upcomingfrom
Controllerdestiny:upcoming
Closed

fix npc not spawning#171
Controllerdestiny wants to merge 2 commits into
SignatureBeef:upcomingfrom
Controllerdestiny:upcoming

Conversation

@Controllerdestiny

Copy link
Copy Markdown

In 1457, you can't directly replace the NewNPCInstanceInSlot method. The NewNPCInstanceInSlot method plays the role of generating NPC packets.

privte static NPC NewNPCInstanceInSlot(int slot, byte generation)
{
	if (Main.netMode == 2 && Main.npc[slot].spawnNeedsSyncing)
	{
		NetMessage.SendData(23, -1, -1, null, slot);
	}
	if (Main.netMode == 1)
	{
		Invariant.Assert(generation != 0, "NewNPCInstanceInSlot called on client without generation?");
	}
	else
	{
		generation = (byte)(Main.npc[slot].generation + 1);
		if (generation == 0)
		{
			generation++;
		}
	}
	NPC nPC = new NPC();
	Main.npc[slot] = nPC;
	nPC.whoAmI = slot;
	nPC.generation = generation;
	ResetNPCSlotData(slot);
	return nPC;
}

@SignatureBeef

Copy link
Copy Markdown
Owner

Missed calling the new function in the 1457 patch - opted to try this bfb4559
Prior this hook was simply to replace the NPC ctor, and no longer is the case.
NPCs seem to spawn now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants