Posted July 19, 20178 yr I have a simple mod intended as a server-side only mod that creates an additional dimension with id 2 using the existing DimensionType DimensionType.OVERWORLD. If a player disconnects after being transferred to this world any attempts to reconnect will result in what appears to be a client-side soft lock (The connection attempt can be cancelled by pressing the cancel button, but will never time-out by itself). If the player is disconnected only after being returned to the default world, they can connect again without any problems. If the server is shut down, the world folder deleted, and the server then started again, the player can also connect again. Used server and MDK version: 1.12 - 14.21.1.2413 What I have tried to fix the issue: - Use a Forge client to connect instead of a vanilla client. - Try calling the function to move the player between worlds from a different event callback. (This failed because ServerChatEvent - which I tried to use - does not appear to catch any chat messages) Other unwanted observed behaviour: - After being transferred from one world to the other, an afterimage of the obsidian block and the redstone torch (see onInteract() in my code for context) are visible in the new world (desync). My code: QuestWorldsEventHandler.java package usr.zyl.questworlds; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.DimensionType; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(acceptableRemoteVersions = "*", modid = QuestWorldsEventHandler.MODID, version = QuestWorldsEventHandler.VERSION) public class QuestWorldsEventHandler { public static final String MODID = "questworlds"; public static final String VERSION = "1.0"; private static QuestWorldsEventHandler questWorldsEventHandler; // DimensionType and dimension id reference (called "canyon" because I wanted to make a canyon lol) public static DimensionType canyonDimensionType; // Just aggressively try to get this id for now (because this is the only mod being run) public static final int canyonDimensionId = 2; public QuestWorldsEventHandler() { } @EventHandler public static void init(FMLInitializationEvent event) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { questWorldsEventHandler = new QuestWorldsEventHandler(); System.out.println("Got ID for our custom world: " + canyonDimensionId); DimensionManager.registerDimension(canyonDimensionId, DimensionType.getById(0)); MinecraftForge.EVENT_BUS.register(questWorldsEventHandler); } } // Warp the player when he places a redstone torch on top of an obsidian block. @SubscribeEvent public void onInteract(PlayerInteractEvent event) { if (FMLCommonHandler.instance().getEffectiveSide() != Side.SERVER) return; if (event == null) return; if (EnumFacing.UP.equals(event.getFace())) { if (EnumHand.MAIN_HAND.equals(event.getHand())) { if (Item.getItemFromBlock(Blocks.REDSTONE_TORCH).equals(event.getItemStack().getItem())) { if (Blocks.OBSIDIAN.equals(event.getWorld().getBlockState(event.getPos()).getBlock())) { EntityPlayer ep = event.getEntityPlayer(); if (ep instanceof EntityPlayerMP) { System.out.println("Warping!"); ep.sendMessage(new TextComponentString("Warping!")); if (ep.dimension == 0) // If in overworld, warp to our dimension warpPlayerToDimension(ep, canyonDimensionId); else // If not in the overworld, warp to the overworld warpPlayerToDimension(ep, 0); } } } } } } // Alternative trigger. Unfortunately this never gets called for unknown reasons. @SubscribeEvent public void onChat(ServerChatEvent event) { if (event == null) return; EntityPlayerMP epmp = event.getPlayer(); String text = event.getComponent().getUnformattedComponentText(); System.out.print("Player \"" + event.getUsername() + "\" sent text: \"" + text + "\""); if (text.startsWith("/warp ")) { String number = text.substring(5, text.length()); try { int dimensionId = Integer.valueOf(number); if (DimensionManager.isDimensionRegistered(dimensionId)) warpPlayerToDimension(epmp, dimensionId); } catch (NumberFormatException ex) {} } } public static boolean warpPlayerToDimension(EntityPlayer ep, int dimension) { return warpPlayerToDimension(ep, dimension, ep.getPosition()); } public static boolean warpPlayerToDimension(EntityPlayer ep, int dimension, BlockPos pos) { if (ep instanceof EntityPlayerMP) { EntityPlayerMP epmp = (EntityPlayerMP) ep; WorldServer ws = epmp.mcServer.getWorld(dimension); BlockPos top = ws.getTopSolidOrLiquidBlock(pos); epmp.mcServer.getPlayerList().transferPlayerToDimension(epmp, dimension, new SimpleTeleporter(ws)); ep.motionX = 0; ep.motionY = 0; ep.motionZ = 0; ep.setPositionAndUpdate(top.getX() + 0.5, top.getY() + 2.5, top.getZ() + 0.5); return true; } return false; } } SimpleTeleporter.java package usr.zyl.questworlds; import net.minecraft.entity.Entity; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; public class SimpleTeleporter extends Teleporter { public SimpleTeleporter(WorldServer worldServer) { super(worldServer); } @Override public void placeInPortal(Entity entityIn, float rotationYaw) { } @Override public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) { return true; } @Override public boolean makePortal(Entity entityIn) { return true; } } Any clues on what might be going wrong here? Edited July 19, 20178 yr by Zyl
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.