Jump to content

How to relocate player? 1.16.5


LemonTree_128bit

Recommended Posts

Hello. Sorry for stupid question.
How do I relocate the player? I tried to use: ServerPlayerEntity#setPos, ServerPlayerEntity#teleportTo and ServerPlayerEntity#moveTo, but all of this methods just dont do anything. What do I do wrong? Here is my code:
 

ServerPlayerEntity player = context_.getSender();
            Entity vehicle = player.getVehicle();
            if (vehicle != null)
                if (vehicle instanceof MahalmulaShipEntity) {
                    if (MahalmulaKeybinds.compareBind(msg.key, MahalmulaKeybinds.TELEPORT_KEY))
                    {
                        if (msg.action != 1) return;
                        ServerWorld destWorld = TeleportationModule.getWorld(player.server, player.getOffhandItem());
                        if (destWorld == null) return;
                        BlockPos pos = MahalmulaDimensionHelper.convertCoordinates(player.blockPosition(), player.level.dimensionType(), destWorld.dimensionType());
                        MahalmulaCustomTeleporter teleporter = new MahalmulaCustomTeleporter(pos);
                        vehicle.remove();
                        ((ShipSpawner)MahalmulaBlocks.SHIP_SPAWNER.get()).rememberBlock(destWorld.getBlockState(pos.above()));
                        destWorld.setBlockAndUpdate(pos.above(), MahalmulaBlocks.SHIP_SPAWNER.get().defaultBlockState());
                        player.changeDimension(destWorld, teleporter);
                        //player.setPos(pos.getX(), pos.getY(), pos.getZ());
                        //player.moveTo(pos.getX(), pos.getY(), pos.getZ());
                        player.teleportTo(pos.getX(), pos.getY(), pos.getZ());
                        //vehicle.setPos(player.blockPosition().getX(), player.blockPosition().getY()-1, player.blockPosition().getZ());
                        ((MahalmulaShipEntity) vehicle).setRiderForced(player);
                    }
                }

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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