Switch dimension for entity procedure block not working

Published by mario2582 on
Issue description

Using the following procedure in the image attached causes the game to crash as soon as you enter the custom dimension i designed. Using the regular portal works fine with it, as soon as a procedure is used to change dimension ID (with or without entering the custom dimension via portal first) the game crashes upon the procedure being triggered and the dimension loading, if you reload the world after it crashes you spawn in the custom dimension via a nether portal.

i want this fixed as soon as possible because i am trying to create a mod where if you fall below the -40 y limit you get teleported to a very weird custom dimension called the Under

Procedure block

 

Issue comments

This is a known bug but with the current implementation, we don't have a good fix for this yet.

Create a new class called TeleporterEmpty (for example). You have to extend net.minecraft.world.Teleporter and override several methods, like this:

package net.nuparu.finalscience.util;

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

public class TeleporterEmpty extends Teleporter {

	public TeleporterEmpty(WorldServer worldIn) {
		super(worldIn);
	}

	public void placeInPortal(Entity entityIn, float rotationYaw) {
	}

	public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) {
		return true;
	}

	public boolean makePortal(Entity entityIn) {
		return true;
	}
}

 

Then create in whatever class you want a static function, that will handle the teleportation:

public static void switchDimension(MinecraftServer server, EntityPlayerMP entity, int dim) {
		PlayerList list = server.getPlayerList();
		list.transferPlayerToDimension(entity, dim, new TeleporterEmpty(server.getWorld(0)));
	}

 

And then just call the function when you want to switch dimension. (Of course use name of your the class where you have created the method instead of "TimeUtils")

TimeUtils.switchDimension(server, (EntityPlayerMP) player, 0);

 

Thank you Nuparu00 for your code example :) I will change the teleport procedure as you suggested so it will work properly.

It's because of the way Minecraft uses travelling between dimensions. Mcreator uses only 'Nether-like' dimensions in terms of portals, so they will search for nearby portals to go through. It's not programmed to do anything else. The End can be gone to via this procedure block, because it uses a different system. Instead of searching for a portal, it just puts you in a specific location. However, this does not scale with the Overworld, so it wouldn't teleport you back very well.

Thank you for fixing this :D

Now different portal shapes, enderdragon return portals-like, spaceships, time machines and much more will be possible to be made! :D