Jump to content

[1.8] Issue setting Dimension spawnpoint


The_SlayerMC

Recommended Posts

I seem to not be able to set my dimensions spawn, Im adding an End like dimension (one floating island) and i spawn way out of where i should be. I've added these into my world provider but i still seem to spawn in at the same position that i would be in the overworld (coords carrying over from the overworld dimension)

@Override
    public boolean canCoordinateBeSpawn(int x, int z) {
        return this.worldObj.getGroundAboveSeaLevel(new BlockPos(x, 0, z)) == EssenceBlocks.corbaStone;
    }

@Override
public BlockPos getRandomizedSpawnPoint() {
	return new BlockPos(0, 63, 0);
}

@Override
public BlockPos getSpawnPoint() {
	return new BlockPos(0, 63, 0);
}

@Override
public void setSpawnPoint(BlockPos pos) {
	super.setSpawnPoint(new BlockPos(0, 63, 0));
}

@Override
    public BlockPos getSpawnCoordinate() {
        return new BlockPos(0, 63, 0);
    }

@Override
    public int getAverageGroundLevel() {
        return 63;
    }

 

I even got so desperate that i called an event:

@SubscribeEvent
public void transferDims(PlayerChangedDimensionEvent e) {
	if(e.toDim == Config.corba) {
		SlayerAPI.addChatMessage(e.player, "In corba");
		e.player.setLocationAndAngles(0, 63, 0, 0.0F, 0.0F);
	}
}

And it prints the message in chat, so why doesnt it set my location..?

 

As always, any help would be muchly appreciated :D

 

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Link to comment
Share on other sites

  • 2 months later...

I have a similar problem right now.

 

I am unable to set the bed spawn point except in 2 special circumstances.

 

I have tried using

player.setSpawnChunk(bedPos, true, playerDimension);

and

player.setSpawnPoint(bedPos, true);

 

The only times I can sucessfully set a bed spawn point is when

1. A new map where no bed point has been set.

or

2. A player death where an actual bed was slept in then destroyed or removed before the death.

This resets its ability to set a bed location with either function above.

 

Both functions seem to set a set of variables or a set of HashMap in EntityPlayer.  But these do not seem to be updating what Minecraft seems to be actually using to determine where to spawn players. 

 

This looks like a BUG either in Forge or Minecraft 1.8.

(ATTENTION FORGE DEV TEAM?)

 

I also tested for this problem in Minecraft 1.7.10 and that version works well.

 

I need this fixed now as well for one of my mods I am trying to sucessfully code for Minecraft 1.8.

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2131444

 

Link to comment
Share on other sites

I went there and read the rules

 

3 points down in first sections it says:

"This is a support forum for players, not for modders needing help with code. Modders go to the Modder Support forum."

 

This here seems to be the modder's support forum unless im confused.

 

Maybe there is a bug reporting thing somewhere.

 

Link to comment
Share on other sites

I have been studying the source code such as EntityPlayer.

 

Its seems right.  I did find a spot the needed a "return;" but doesnt hurt anything if its not there.  If you use setSpawnChunk(...) with a good playerPos in dimension 0 it should do a "return;" right after setting the spawnChunk and spawnForced variables.  BUT it drops past that and adds an entry in the hash map for other dimension bed spawns for dimension 0 but that shouldnt really bother anything.

 

When the player wakes it can call the setSpawnPoint(..) function.  This seems normal.

 

So my next thought is that when I respawn from death why does it send me to the bed location that is wrong? 

 

So where is the code for when "You died" screen shows up and you then hit the button "respawn" ?  Its not picking the right respawn location in every circumstance.

 

So I can set the bed spawn with setSpawnPoint or setSpawnChunk but that is NOT where the "respawn" button sends me.  Where is that code?  I need help. 

 

Link to comment
Share on other sites

On the Gui 'GuiGameOver', when you clickes Respawn button, It calls EntityPlayerSP#respawnPlayer().

It sends the packet 'C16PacketClientStatus' with the flag 'PERFORM_RESPAWN'.

When the Server gets the packet, it ensures that the player really died,

and call ServerConfigurationManager#recreatePlayerEntity(EntityPlayerMP playerIn, int dimension, boolean conqueredEnd)

There it removes the died player and create a 'clone' player.

 

At there, it gets the spawn position by EntityPlayer#getBedSpawnLocation(World worldIn, BlockPos bedLocation, boolean forceSpawn). (the bedLocation parameter is set to the EntityPlayer#getBedLocation(dimension) )

I inspected the code, and I cannot find any clue for the problem.

 

..Wait, where did you put EntityPlayer#setSpawnPoint(bedPos, true);

Since it seems that WorldProvider methods related with spawning is not automatically called when the spawn point is not set.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

my guess would be that the world's spawnpoint is only used for spawning in new players, and the player's bed location is used otherwise, and that may default to the world's spawnpoint. Just a guess from reading the thread, I don't have time to dig into code right now.

Link to comment
Share on other sites

 

SOLUTION FOUND!

 

Ok, so, lol.  I found the problem.  It was so small and so simple that I feel stupid.

 

In my defence: I did multiple checks of my code and studied Minecraft and Forge code for hours.  I learned a bit.  :)

 

The problem with the bug was totally mine and was NOT a bug in forge or minecraft at all.  When I upgraded my code to mc1.8 I changed 1 tiny little thing from a set of coordinates to a BlockPosition and it was wrong. LOL.  oops!  This will be released in a new version of SpawnCommands Teleport mod soon.

 

I actually learned a bit from studying the Minecraft and Forge source code.  It was long and fun.

 

Im adjusting to other minor things as well.  This may take a few days to get the update out for my mod as life does interfere with the coding fun.

 

My apologies and appreciation to those that make Mineraft and MinecraftForge!  :)

 

 

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



×
×
  • Create New...

Important Information

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