Jump to content

1.7 - Teleporter not working spawn


Casual Dutchman

Recommended Posts

I have made a portal, a dimension and a teleporter. It works great, except for one thing.

The teleporter

When I enter my dimension I spawn at the portal.

When I enter the overworld again, I spawn at the exact same coordinates as the portal in my dimension.

 

I think it has to do with this code:

int j2 = par1Entity.getTeleportDirection();

 

Lets start from the beginning from where this code starts.

It begin in the BlockPortal class.

When it calles for the entity.setInPortal() it create a new integer

teleportDirection = Direction.getMovementDirection(d0, d1)

 

the getTeleportDirection() get the 'teleportDirection' from the Entity class.

but this is not set when I have my own code for the portal black;

 

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
 {
	 if ((par5Entity.ridingEntity == null) && (par5Entity.riddenByEntity == null) && ((par5Entity instanceof EntityPlayerMP)))
	 {			
		 EntityPlayerMP player = (EntityPlayerMP) par5Entity;
		 MinecraftServer mServer = MinecraftServer.getServer();
		 if (player.timeUntilPortal > 0)
		 {
			 player.timeUntilPortal = 10;
		 }
		 else if (player.dimension != AgeCraft.dimensionId)
		 {
			 player.timeUntilPortal = 10;
			 player.mcServer.getConfigurationManager().transferPlayerToDimension(player, AgeCraft.dimensionId, new TeleporterSadiraj(mServer.worldServerForDimension(AgeCraft.dimensionId)));
		 }
		 else
		 {
			 player.timeUntilPortal = 10;
			 player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new TeleporterSadiraj(mServer.worldServerForDimension(1)));
		 }

	 }
 }

 

Can anyone help me with this code?

Coding, Testing, Smiling, Publishing!

Link to comment
Share on other sites

You might try lookingg at Wuppy's Tutorials on Custom Dimensions.

 

I never had much luck doing it the way you are listing.  I created my own code to determine where the player landed so I could have custom ratio's per dimension and some other functionality.  That however, is a big endevor to get everything to work right.

 

Wuppy's is probably a better solution for something simpler to undrestand and compare to yours.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

You might try lookingg at Wuppy's Tutorials on Custom Dimensions.

 

I never had much luck doing it the way you are listing.  I created my own code to determine where the player landed so I could have custom ratio's per dimension and some other functionality.  That however, is a big endevor to get everything to work right.

 

Wuppy's is probably a better solution for something simpler to undrestand and compare to yours.

I know, I did that. I followed the tutorial and it worked.

only when I enter the overworld again, it will spawn me at the same coordinates as the portal in my custom dimension. I can spawn really high or in the ground, even with an existing portal in the overworld. I dont get it!

Coding, Testing, Smiling, Publishing!

Link to comment
Share on other sites

When I looked a it, there was some decisions and data that was stored in the player and in a few other places that the custom teleporter didn't touch.

 

Based on that and how I wanted to use it is why I moved to just creating my own custom teleportation and gate system.  If you figure it out, be sure to post for others.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

  • 2 months later...

OK so I saw your post trying to see if anyone had my problem. Your problem was my problem EXACTLY. However, I figured out how to fix it. In player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new TeleporterSadiraj(mServer.worldServerForDimension(1)));

you have to set the worldServerForDimension(int) to 0 not 1.

 

If its important to you (or whomever else has this problem) to understand code rather than copypaste (like it is for myself) then here is the process through which I went through to figure out the problem:

  First of all i figured EXACTLY what was going wrong. What was happening, as you explained, was that going to a custom dimension worked fine but coming back to the overworld made the player spawn at the EXACT coords that were stored at the location of the player when teleporting. This caused the player to spawn either in the ground or above the ground. So what i figured at first was that something must be going wrong in the teleport class but then i looked at the code that brought me to the tele class in the first place. The portal block class. You were right again at where the problem was (inside of onEntityCollideWithBlock). So i looked into this method (idk if that's the right word I'm still learning) and found where it was calling the custom tele class. It was a method from the ServerConfigurationManager class (transferPlayerToDimension). I saw in eclipse when i hovered over the method that it said that the last parameter was teleporter. I looked at my code and wuppy's and saw the same. Then, more importantly i noticed the parameter in the tele parameter. It was there i realized that there are separate numbers in the first and second callings of the method (tranferplayer...) so i looked at both of them. One was set to be my dimension id and one was set to be 1 corresponding with the overworld id. So i tried to figure out the difference for why they would need to be there. my dimension id was in the else if statement that basically said to go to my dim if i wasn't already there. the else statement said that if I'm in my dimension, go back to the overworld. Using this info i figured that teleport was doing its job just fine (since it worked one way but not the other) but it was the different parameters that i was passing that upset the cycle. So i changed the 1 into a 0 ran MC and it worked. I assume that the spawn coord modifier was being used as if the player was spawning in the end (dimId of 1)and that's why it didn't work. Hopefully my spelling wasn't too terrible and my explanation was at least OK, just wanted to make sure anyone who could learn from this would be able to rather than just copy paste like so many tuts that Ive seen would have you do rather than explain. Wuppy's tuts are really good at explaining most things its just that it was 1.6 code that i don't think he updated in his 1.7 update videos (like he forgot to do this part, i realize that the video exists).

 

-bloxy, a well known modder (someday eventually :P)

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.