Jump to content

[1.7.2][Dimension]entity.travelToDimension issues


muddyfish

Recommended Posts

When I am teleporting entities to my dimension using "entity.travelToDimension([Dimension ID]);", it always creates a nether portal frame and never teleports to the correct position.

Is there another method I can use to achieve the same affect of moving the entity from one dimension to another without the nether portal that takes XYZ coordinates and the dimension id?

If not, can you point me in the right direction with coding my own method?

 

UPDATE: I now have a custom teleporter class that extends Teleporter and call it when I am teleporting

Link to comment
Share on other sites

I had already done so.

I have narrowed it down to this line in my travel function which never returns.

If I disconnect from the game then reconnect, I have travelled properly.

                worldserver1.spawnEntityInWorld(newEntity);

(Entire function based on Entity.java's travelToDimension)

public void teleportEntityToDimension(World world, Entity entity, int travelDimension) {
        if (!world.isRemote && !entity.isDead) {
            world.theProfiler.startSection("changeDimension");
            MinecraftServer minecraftserver = MinecraftServer.getServer();
            int dimension = entity.dimension;
            WorldServer worldserver = minecraftserver.worldServerForDimension(dimension);
            WorldServer worldserver1 = minecraftserver.worldServerForDimension(travelDimension);
            entity.dimension = travelDimension;
            
            world.removeEntity(entity);
            entity.isDead = false;
            world.theProfiler.startSection("reposition");
            minecraftserver.getConfigurationManager().transferEntityToWorld(entity, dimension, worldserver, worldserver1, new Teleporter(worldserver));
            world.theProfiler.endStartSection("reloading");

            Entity newEntity = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);
            if (newEntity != null)
            {
                newEntity.copyDataFrom(entity, true);
                worldserver1.spawnEntityInWorld(newEntity);
            }
            entity.isDead = true;
            world.theProfiler.endSection();
            worldserver.resetUpdateEntityTick();
            worldserver1.resetUpdateEntityTick();
            world.theProfiler.endSection();
        }
}

Link to comment
Share on other sites

If you are transporting a player use

        	if (entity instanceof EntityPlayerMP) {
                   EntityPlayerMP player = (EntityPlayerMP) entity;
                   player.mcServer.getConfigurationManager().transferPlayerToDimension(player, travelDimension, new Teleporter(minecraftServer.worldServerForDimension(player.dimension)));
                   newEntity = player;
        	}

instead of the last code I posted and it works nicely. (Got of wuppy's tutorial for teleporters)

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were intended to be used on tutorial posts so that people could easily find tutorials based on their skill level, but instead the tags were abused for unrelated things that made the original intent useless... for example, people often posted crash reports with the "beginner" tag, so instead of finding tutorials for beginners, you got crash reports showing up in searches.
    • The crash says: Exception caught when registering wandering trader java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.m_9236_()" because "entity" is null at com.telepathicgrunt.repurposedstructures.misc.maptrades.StructureSpecificMaps$TreasureMapForEmeralds.m_213663_(StructureSpecificMaps.java:53) ~[repurposed_structures-7.1.15+1.20.1-forge.jar%23708!/:?] at jeresources.collection.TradeList.addMerchantRecipe(TradeList.java:58) ~[JustEnoughResources-1.20.1-1.4.0.247.jar%23630!/:1.4.0.247] JustEnoughResources is mentioned, too Does it work without one of these mods?
    • I have been trying to place a jigsaw structure for about a week now and cant get it to work. I have the template pool etc set up and working it does randomly generate now I just want to place it in the world using a coded trigger. I cant seem to find any useful information on the internet and am completely stuck I think I need to use : JigsawPlacement.generateJigsaw() But I cant get the Holder<StructureTemplatePool>
    • There are more - maybe   watut, whatdurability, playeranimator and vanillafix
    • cen you be a bit more specific pls there are many mods in the log mentioned by name does any error mention it or something couse when i search on   repurposed_structures i dont find anything helpfull cen you tell me which line you say that it might couse the problem?
  • Topics

×
×
  • Create New...

Important Information

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