Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

i made an item that if you right click it, it will transfer you to a dimension, but everytime i right click it, it brings me to the dimension, but instantly teleports me to hell. Help pls. This is my code. Reply if you need more parts of it.

package com.mrfloatingcow.items;

import com.mrfloatingcow.dimensions.dimensionRegistry;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.world.World;

public class rbSword extends ItemSword{

public rbSword(ToolMaterial p_i45356_1_) {
	super(p_i45356_1_);
}

public ItemStack onItemRightClick (ItemStack par1ItemStack, World par2World, EntityPlayer Player){

	EntityPlayer player = (EntityPlayer) Player;
	player.travelToDimension(dimensionRegistry.dimensionIdRainbow);
	return par1ItemStack;


}

}

I don't see anything blatant that would cause that, you could try the way I did it, with packets, which also affords you more control over how the player is placed in the destination dimension:

 

 

Main class:

public static SimpleNetworkWrapper snw;


@EventHandler
public void preinit(FMLPreInitializationEvent event)
{
	snw = NetworkRegistry.INSTANCE.newSimpleChannel(modid);
	snw.registerMessage(MessageTeleportToDimension.TeleportHandler.class, MessageTeleportToDimension.class, idnumber, Side.SERVER);
}

 

 

Packet:

public class MessageTeleportToDimension implements IMessage
{
int dim;
int id;


public MessageTeleportToDimension(){}


public MessageTeleportToDimension(int dim, int id)
{
	this.dim = dim;
	this.id = id;
}


@Override
public void fromBytes(ByteBuf buf)
{
	this.dim = buf.readInt();
	this.id = buf.readInt();
}


@Override
public void toBytes(ByteBuf buf)
{
	buf.writeInt(this.dim);
	buf.writeInt(this.id);
}


public static class TeleportHandler implements IMessageHandler<MessageTeleportToDimension, IMessage>
{
	@Override
	public IMessage onMessage(MessageTeleportToDimension message, MessageContext ctx)
	{
		Entity ent = ctx.getServerHandler().playerEntity.worldObj.getEntityByID(message.id);
		if(ent instanceof EntityPlayerMP)
		{
			EntityPlayerMP player = (EntityPlayerMP)ent;
			player.mcServer.getConfigurationManager().transferPlayerToDimension(player, message.dim, new CustomTeleporter(player.mcServer.worldServerForDimension(message.dim)));
			player.fallDistance = 0.0f;
		}
		return message;
	}
}
}

 

 

Custom Teleporter (I used this to teleport the player to the overworld without forming a Nether portal, this is where your placement logic would go)

public class CustomTeleporter extends Teleporter
{
final WorldServer worldServer;


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


@Override
public boolean makePortal(Entity entity){~}


@Override
public void placeInPortal(Entity entity, double x, double y, double z, float yaw){~}
}

 

 

OnRightClick:

MainClass.snw.sendToServer(new MessageTeleportToDimension(dimensionid, player.getEntityId()));

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.