I everything working up to the point of actually teleporting the player. Here is the code located in the GUI class:
@Override
public void actionPerformed(GuiButton button)
{
playerIn.closeScreen();
playerIn.travelToDimension(1);
}
The GUI closes, but the player does not travel to the End (which I am just using as the placeholder dimension for now). I have narrowed it down to two issues:
1) playerIn is an instance of EntityPlayer, not EntityPlayerMP, which will be an issue later when I change the code to teleport the player to the dimension I have set up.
2) The worldObj in playerIn is remote, which I believe is the main reason that this is not working.
If you could help me on these two issues, your help would be truly appreciated.
Try replacing playerIn with a variable defined by you that is of the type EntityPlayerMP. For the second issue you could use Minecraft.getMInecraft().theWorld instead of the worldObj in playerIn.
Rollback Post to RevisionRollBack
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
Try replacing playerIn with a variable defined by you that is of the type EntityPlayerMP. For the second issue you could use Minecraft.getMInecraft().theWorld instead of the worldObj in playerIn.
The problem is though that I can't cast from EntityPlayer to EntityPlayerMP. My playerIn variable is the one passed onto the Gui by my GuiHandler. Even if I did make a variable with the type EntityPlayerMP, I would need to get the EntityPlayerMP instance from somewhere.
The problem is though that I can't cast from EntityPlayer to EntityPlayerMP. My playerIn variable is the one passed onto the Gui by my GuiHandler. Even if I did make a variable with the type EntityPlayerMP, I would need to get the EntityPlayerMP instance from somewhere.
Right. This isn't working because you need to teleport the instance of the player that is on the server, and whenever you are in GUI code, you only have an instance on the client. If it does anything, it will only be transitory. It may show you teleported for a sec, then you are right back where you started when the client syncs back up to the server side. This actionPerformed is only running on the client side, you need to find another location in your code to trigger this that runs on the server side.
You don't show the rest of your code, so I can't say where this might be. Some places to look are in maybe the Tile Entity that goes with the GUI, or an event that fires when the GUI is closed. From that location you can get an instance of the world and player and do the teleport.
Right. This isn't working because you need to teleport the instance of the player that is on the server, and whenever you are in GUI code, you only have an instance on the client. If it does anything, it will only be transitory. It may show you teleported for a sec, then you are right back where you started when the client syncs back up to the server side. This actionPerformed is only running on the client side, you need to find another location in your code to trigger this that runs on the server side.
You don't show the rest of your code, so I can't say where this might be. Some places to look are in maybe the Tile Entity that goes with the GUI, or an event that fires when the GUI is closed. From that location you can get an instance of the world and player and do the teleport.
I found a fix. It's a bit complicated to explain, but I'll try. Basically, I passed the server's container instance of my GUI into the client as a parameter. From the client GUI I then triggered a function in the container GUI (which is server side) to teleport the player. Now that works, but I realized something is broken in my Teleporter code, so now I have to try and fix that...
I everything working up to the point of actually teleporting the player. Here is the code located in the GUI class:
@Override
public void actionPerformed(GuiButton button)
{
playerIn.closeScreen();
playerIn.travelToDimension(1);
}
The GUI closes, but the player does not travel to the End (which I am just using as the placeholder dimension for now). I have narrowed it down to two issues:
1) playerIn is an instance of EntityPlayer, not EntityPlayerMP, which will be an issue later when I change the code to teleport the player to the dimension I have set up.
2) The worldObj in playerIn is remote, which I believe is the main reason that this is not working.
If you could help me on these two issues, your help would be truly appreciated.
Try replacing playerIn with a variable defined by you that is of the type EntityPlayerMP. For the second issue you could use Minecraft.getMInecraft().theWorld instead of the worldObj in playerIn.
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
The problem is though that I can't cast from EntityPlayer to EntityPlayerMP. My playerIn variable is the one passed onto the Gui by my GuiHandler. Even if I did make a variable with the type EntityPlayerMP, I would need to get the EntityPlayerMP instance from somewhere.
*bump*
Right. This isn't working because you need to teleport the instance of the player that is on the server, and whenever you are in GUI code, you only have an instance on the client. If it does anything, it will only be transitory. It may show you teleported for a sec, then you are right back where you started when the client syncs back up to the server side. This actionPerformed is only running on the client side, you need to find another location in your code to trigger this that runs on the server side.
You don't show the rest of your code, so I can't say where this might be. Some places to look are in maybe the Tile Entity that goes with the GUI, or an event that fires when the GUI is closed. From that location you can get an instance of the world and player and do the teleport.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
I found a fix. It's a bit complicated to explain, but I'll try. Basically, I passed the server's container instance of my GUI into the client as a parameter. From the client GUI I then triggered a function in the container GUI (which is server side) to teleport the player. Now that works, but I realized something is broken in my Teleporter code, so now I have to try and fix that...
Ah, it is always something Sound like you are on your way to getting it working though.
Glad I could help. How about you click the little green arrow, I'm trying to go over 50 thanks
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]