Jump to content

Recommended Posts

Posted

Dose anyone know how to send a player to another dimension (any dimension) without the problem with nether portals spawning?

 

My goal is to come up with a method that works almost exactly like the mystcraft txp command. So I would give it the player the dimension id and the x y z coordinates I want the player sent to.

 

I have looked at the travelToDimension method but I cant figure out exactly how it works any ideas?

 

It would be really nice if we could come up with something that works because I have seen a few posts about this but no one that i have seen has been able to come up with a good solution.

I am the author of Draconic Evolution

Posted

Just create a custom Teleport class and use it.

 

 

Here is a simple version i did for something.  You just need to change out the method associated with location destination.  I don't have it in this version, but you also want to set the player's fall distance to zero when setting the motion.

 

 

 

 

public class MyTeleporter extends Teleporter {

 

    // Setup Variables

    public Dimension_Multiplyer instance = Dimension_Multiplyer.instance;

 

    // Setup Specific Variables

    private WorldServer worldserver;

 

    public MyTeleporter(WorldServer worldserver) {

        super(worldserver);

       

        // Setup Variables

        this.worldserver = worldserver;

       

    }

 

    // Move the Entity to the portal

    public void teleport(Entity entity, World world) {

   

        // Setup Variables

        EntityPlayerMP playerMP = (EntityPlayerMP) entity;

       

        // Get name of world

        String world_name = instance.world_manager().name(world.provider.dimensionId);

       

        // Set default location

        double dx = 0;

        double dy = 0;

        double dz = 0;

       

        // Check world_properties for spawn

        World_Properties world_property = instance.world_manager().world_properties().get(world.provider.dimensionId);

 

        if (world_property != null) {

       

            dx = world_property.spawn_x();

            dy = world_property.spawn_y();

            dz = world_property.spawn_z();

           

        }

 

        // check for zeros

        if (dx == 0 && dy == 0 && dz == 0) {

       

            // Set height to something big

            dy = 250;

 

            // Drop down until find solid

            while (world.getBlock((int) dx, (int) dy - 1, (int) dz).equals(Blocks.air) && dy > 0) {

           

                dy--;

               

            }

 

            // Last check if dy == 0

            if (dy == 0) {

           

                dy = 128;

               

            }

           

        }

 

        // Offset locations for accuracy

        dx = dx + 0.5d;

        dy = dy + 1.0d;

        dz = dz + 0.5d;

        entity.setPosition(dx, dy, dz);

       

        // Freeze motion

        entity.motionX = entity.motionY = entity.motionZ = 0.0D;

        entity.setPosition(dx, dy, dz);  // silly to do this multiple time,s but it kept offseting entity until this was done

 

        // Set Dimension

        if (entity.worldObj.provider.dimensionId != world.provider.dimensionId) {

       

            playerMP.mcServer.getConfigurationManager().transferPlayerToDimension(playerMP, world.provider.dimensionId, this);

           

        }

 

        entity.setPosition(dx, dy, dz); // silly to do this multiple time,s but it kept offseting entity until this was done

        // instance.logger.log(Level.INFO, "Teleported to " + world_name + ":" + dx + "/" + dy + "/" + dz);

   

    }

 

    // Override Default BS

    @Override

    public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8)

    {

        return false;

    }

 

    @Override

    public void removeStalePortalLocations(long par1)

    {

    }

 

    @Override

    public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8)

    {

    }

   

}

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I just started playing with a custom teleport class but so far i haven't been able to get it to work properly (when teleporting to the overworld the world dosnt load until you relog)

 

I will check out yours and see what im doing wrong thanks!

 

Edit: What are "Dimension_Multiplyer" & "World_Properties"?

I am the author of Draconic Evolution

Posted

Name of things from my mod.  you will want to get rid of them and put in your own references.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

The following snipet is inside of a command call.  But this won't help you that much.  As I said before, I've got system tracking things for each world, such as where i want to spawn in from a teleport to it.  You will either need to do that or just specify a constant.  If you do that, you will need to search based upon x,z what the topmost y is each time.

 

 

 

 

// move the player to the world

                new MyTeleporter(minecraftserver.worldServerForDimension(world.provider.dimensionId)).teleport(player, world);

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

This is what i have atm its very basic but it almost works

 

import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;

public class CustomTeliporter extends Teleporter
{

private final WorldServer worldServerInstance;

public CustomTeliporter(WorldServer worldServer) {
	super(worldServer);
	this.worldServerInstance = worldServer;
}

@Override
public void placeInPortal(Entity entity, double x, double y, double z, float r)
{
	y = this.worldServerInstance.getTopSolidOrLiquidBlock((int) x, (int) z);
	entity.setLocationAndAngles(x, y, z, entity.rotationYaw, 0.0F);
}

@Override
public void removeStalePortalLocations(long par1)
{
}

@Override
public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
{
	return false;
}
}

 

And i made an item to test it. (right click teleports you to ether the end or the nether depending on which you are currently in shift right click teliports you to the dimension you are currently in)

 

@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
if (player instanceof EntityPlayerMP)
{
	EntityPlayerMP thePlayer = (EntityPlayerMP) player;

	double x = thePlayer.posX;
	double y = thePlayer.posY;
	double z = thePlayer.posZ;
	if (!thePlayer.isSneaking())
	{
		if (thePlayer.dimension == -1)
		{
			thePlayer.setPositionAndRotation(x + 0.5D, thePlayer.posY, z + 0.5D, thePlayer.rotationYaw, thePlayer.rotationPitch);
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 1, new CustomTeliporter(thePlayer.mcServer.worldServerForDimension(1)));
		} else
		{
			thePlayer.setPositionAndRotation(x + 0.5D, thePlayer.posY, z + 0.5D, thePlayer.rotationYaw, thePlayer.rotationPitch);
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, -1, new CustomTeliporter(thePlayer.mcServer.worldServerForDimension(-1)));
		}
	} else
	{
		thePlayer.setPositionAndRotation(x + 0.5D, thePlayer.posY, z + 0.5D, thePlayer.rotationYaw, thePlayer.rotationPitch);
		thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, thePlayer.dimension, new CustomTeliporter(thePlayer.mcServer.worldServerForDimension(thePlayer.dimension)));
	}
}
return stack;
}

 

The problem i am having is when you teleport from the the end to ether the overworld or the nether the world dosnt seem to lead client side. The world is definitely loading because you can still collide with blocks (in a very glitchy way) even though you cant see them. If you teleport again it fixes it.

I am the author of Draconic Evolution

Posted

I was completely lost as to why the world wont load when teleporting from the end. I started thinking it may be a forge problem so to test this i went and found a 1.7.2 mod thats adds inter dimensional travel (found this http://www.minecraftforum.net/topic/2266303-172164teleportation-warp-book/) and loaded it up with the latest forge release and sure enough when teleporting from the end to any other dimension the world dosnt load. So ether this mod is broken or there is a problem with forge.

 

Edit: ok maby that mod was a bad test subject i went as far back as forge 1049 and it still didnt work properly. It also sometimes spawned portals when travelling between the overworld and the nether which leads me to believe it just uses the  travelToDimension method.

 

Edit: This is just so weird the world is definitely being loaded. I can here mobs and see the particle effects from sheep eating grass and i can even pick up items on the ground but all i see it this:

SreX4Um.png

 

I am the author of Draconic Evolution

Posted

For now i guess i will have to settle for running teleporting the player twice if they are teleporting from the end.

If anyone is interested this is the final code. What it gives me is a method "Teleporter.teleport(player, x, y, z, dimension);" which works exactly as you would expect teleports the given player to the given x, y, z coordinates in the given dimension and it seems to work fairly well.

 

Teleporter class

 

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;

public class Teleporter
{
public static void teleport(EntityPlayer player, double x, double y, double z, int dim)
{
	if (player instanceof EntityPlayerMP)
	{
		EntityPlayerMP thePlayer = (EntityPlayerMP) player;

		if (player.dimension == dim)
		{
			player.setLocationAndAngles(x, y, z, player.rotationYaw, player.rotationPitch);
		} else if (thePlayer.dimension == 1)
		{      //If teleporting from the end this has to be run twice or the world wont load properly
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z));
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z));
		} else
		{
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z));
		}
	}
}
}

 

CustomeTeleporter class

 

import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;

public class CustomTeleporter extends Teleporter
{
private double tX;
private double tY;
private double tZ;

public CustomTeleporter(WorldServer worldServer, double tX, double tY, double tZ) {
	super(worldServer);

	this.tX = tX;
	this.tY = tY;
	this.tZ = tZ;
}

@Override
public void placeInPortal(Entity entity, double x, double y, double z, float r)
{
	entity.setLocationAndAngles(this.tX, this.tY, this.tZ, entity.rotationYaw, entity.rotationPitch);
}

@Override
public void removeStalePortalLocations(long par1)
{
}

@Override
public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
{
	return false;
}
}

 

Example implementation:

 

@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
if(player.dimension == -1)
	Teleporter.teleport(player, 0, 100, 0, 0);
else if(player.dimension == 0)
	Teleporter.teleport(player, 0, 100, 0, 1);
else if(player.dimension == 1)
	Teleporter.teleport(player, 0, 100, 0, -1);

return stack;
}

 

 

 

I am the author of Draconic Evolution

Posted

Sorry for the slow response.  I occasionally have the issue you are describing.  I haven't been able to figure out why.  Its pretty dang annoying.

 

There is probably a packet to the client that isn't happening right with how we are doing this.  I'll look around a bit tonight and see if I spot anything.

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

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.